Cannot create Maven Project in eclipse

前端 未结 10 2240
太阳男子
太阳男子 2020-11-30 00:13

I have Eclipse Luna and Maven 3.2.3 installed on a Windows 7 machine behind a corporate firewall.

Trying to create a project from an archetype results in the follow

相关标签:
10条回答
  • 2020-11-30 00:48

    Same problem here, solved.

    I will explain the problem and the solution, to help others.

    My software is:

    Windows 7
    Eclipse 4.4.1 (Luna SR1)
    m2e 1.5.0.20140606-0033
        (from eclipse repository: http://download.eclipse.org/releases/luna)
    

    And I'm accessing internet through a proxy.

    My problem was the same:

    • Just installed m2e, went to menu: File > New > Other > Maven > Maven project > Next > Next.
    • Selected "Catalog: All catalogs" and "Filter: maven-archetype-quickstart", then clicked on the search result, then on button Next.
    • Then entered "Group Id: test_gr" and "Artifact Id: test_art", then clicked on Finish button.
    • Got the "Could not resolve archetype..." error.

    After a lot of try-and-error, and reading a lot of pages, I've finally found a solution to fix it. Some important points of the solution:

    • It uses the default (embedded) Maven installation (3.2.1/1.5.0.20140605-2032) that comes with m2e.
    • So no aditional (external) Maven installation is required.
    • No special m2e config is required.

    The solution is:

    • Open eclipse.
    • Restore m2e original preferences (if you changed any of them): Click on menu: Window > Preferences > Maven > Restore defaults. Do the same for all tree items under "Maven" item: Archetypes, Discovery, Errors/Warnings, Instalation, Lifecycle Mappings, Templates, User Interface, User Settings. Click on "OK" button.
    • Copy (for example to a notepad window) the path of the user settings file. To see the path, click again on menu: Window > Preferences > Maven > User Settings, and the path is at the "User settings" textbox. You will have to write the path manually, since it is not posible to copy-and-paste. After coping the path to the notepad, don't close the Preferences window.
    • At the Preferences window that is already open, click on the "open file" link. Close the Preferences window, and you will see the "settings.xml" file already openned in a Eclipse editor.
    • The editor will have 2 tabs at the bottom: "Design" and "Source". Click on "Source" tab. You will see all the source code (xml).
    • Delete all the source code: Click on the code, press control+a, press "del".
    • Copy the following code to the editor (and customize the uppercased values):
    <settings>
      <proxies>
       <proxy>
          <active>true</active>
          <protocol>http</protocol>
          <host>YOUR.PROXY.IP.OR.NAME</host>
          <port>YOUR PROXY PORT</port>
          <username>YOUR PROXY USERNAME (OR EMPTY IF NOT REQUIRED)</username>
          <password>YOUR PROXY PASSWORD (OR EMPTY IF NOT REQUIRED)</password>
          <nonProxyHosts>YOUR PROXY EXCLUSION HOST LIST (OR EMPTY)</nonProxyHosts>
        </proxy>
      </proxies>
    </settings>
    
    • Save the file: control+s.
    • Exit Eclipse: Menu File > Exit.
    • Open in a Windows Explorer the path you copied (without the filename, just the path of directories).
    • You will probaly see the xml file ("settings.xml") and a directoy ("repository"). Remove the directoy ("repository"): Right click > Delete > Yes.
    • Start Eclipse.
    • Now you will be able to create a maven project: File > New > Other > Maven > Maven project > Next > Next, select "Catalog: All catalogs" and "Filter: maven-archetype-quickstart", click on the search result, then on button Next, enter "Group Id: test_gr" and "Artifact Id: test_art", click on Finish button.

    Finally, I would like to give a suggestion to m2e developers, to make config easier. After installing m2e from the internet (from a repository), m2e should check if Eclipse is using a proxy (Preferences > General > Network Connections). If Eclipse is using a proxy, the m2e should show a dialog to the user:

    m2e has detected that Eclipse is using a proxy to access to the internet.
    Would you like me to create a User settings file (settings.xml) for the embedded 
    Maven software?
    
    [ Yes ] [ No ]
    

    If the user clicks on Yes, then m2e should create automatically the "settings.xml" file by copying proxy values from Eclipse preferences.

    0 讨论(0)
  • 2020-11-30 00:48

    Just delete the ${user.home}/.m2/repository/org/apache/maven/archetypes to refresh all files needed, it worked fine to me!

    0 讨论(0)
  • 2020-11-30 00:49

    In my case following solution worked.

    1. Delete RELEASE directory & resolver-status.properties file in your local Maven repository under directory .m2/../maven-archetype-quickstart.
    2. Create Maven project in Eclipse or STS (Spring Tool Suite). It will automatically download quickstart archetype & work as expected.

    I hope this may help someone.

    0 讨论(0)
  • 2020-11-30 00:49

    I had the same error show up while creating the project but I wasn't behind a proxy and hence the above solutions did not work for me.

    I found this forum. It suggested to:

    1. Delete or Rename .m2 directory from your HOME directory

    In Windows - C:\Users\<username>\Windows

    OR

    In Linux - /home/<username>
    
    1. restart the Eclipse / STS spring tool suite (which am using)

    It worked!

    0 讨论(0)
提交回复
热议问题