不能在eclipse中创建Maven项目 [英] Cannot create Maven Project in eclipse

查看:230
本文介绍了不能在eclipse中创建Maven项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Eclipse Luna和Maven 3.2.3安装在企业防火墙后面的Windows 7机器上。



尝试从原型创建项目会导致以下错误:


无法从任何已配置的存储库解析原型org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE。



无法解析工件org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE



无法解析org.apache.maven.archetypes的版本:maven-archetype-
quickstart:pom:RELEASE:找不到元数据org.apache.maven.archetypes:maven-archetype-quickstart / maven-metadata。 xml in local(C:\Users\xxxx.m2\repository)



无法解析org.apache.maven.archetypes的版本:maven-archetype- quickstart:pom:RELEASE:无法在本地(C:\Users\xxxx.m2\repository)中找到元数据org.apache.maven.archetypes:maven-archetype-quickstart / maven-metadata.xml


代理详细信息在 .m2 / settings.xml 中配置,并从archtype在命令行中工作正常。



我尝试从这里,但没有工作。远程目录也不可接受。我认为这是Eclipse的网络设置问题。我还查看了这个错误报告,尝试找到一些线索和真的不了解如何实现解决方法。



这是我的settings.xml文件:

 < settings xmlns =http://maven.apache.org/SETTINGS/1.0.0
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd\"> ;
< servers>
< server>
< id> nexus< / id>
< username> xxxx@xxxx.com< / username>
< password> {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}< / password>
< / server>
< server>
< id> deployment< / id>
< username> xxxx@xxxx.com< / username>
< password> {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}< / password>
< / server>
< / servers>
< mirrors>
< mirror>
<! - 将其他所有内容发送到/ public - >
< id> nexus< / id>
< mirrorOf> *< / mirrorOf>
< url> https://nexus-int.xxxx.xxxx.com/nexus/content/groups/public< / url>
< / mirror>
< / mirrors>
<个人资料>
<个人资料>
< id> nexus< / id>
<! - 启用内置中央repo的快照直接 - >
<! - 通过镜像对nexus的所有请求 - >
< repositories>
< repository>
< id> central< / id>
< url> http:// center< / url>
< releases>< enabled> true< / enabled>< / releases>
< snapshots>< enabled> true< / enabled>< / snapshots>
< / repository>
< / repositories>
< pluginRepositories>
< pluginRepository>
< id> central< / id>
< url> http:// center< / url>
< releases>< enabled> true< / enabled>< / releases>
< snapshots>< enabled> true< / enabled>< / snapshots>
< / pluginRepository>
< / pluginRepositories>
< / profile>
< / profiles>
< activeProfiles>
<! - 使配置文件始终处于活动状态 - >
< activeProfile> nexus< / activeProfile>
< / activeProfiles>
< / settings>

任何想法?



谢谢

Tomer

解决方案

同样的问题,解决



我将解释问题和解决方案,以帮助他人。



我的软件是: / p>

  Windows 7 
Eclipse 4.4.1(Luna SR1)
m2e 1.5.0.20140606-0033
(从eclipse存储库:http://download.eclipse.org/releases/luna)

我正在通过代理访问互联网。



我的问题是一样的:




  • 刚刚安装了m2e,进入菜单:文件>新建>其他> Maven> Maven项目>下一步>下一步。

  • 选择目录:所有目录然后点击搜索结果,然后点击Next。

  • 然后输入Group Id:test_gr和Artifact Id:test_art,然后点击完成按钮。




经过大量的尝试和错误,并且阅读了很多页面,我终于找到了解决方案。解决方案的一些重点




  • 它使用默认(嵌入式)Maven安装(3.2.1 / 1.5.0.20140605-2032)由m2e提供。

  • 所以不需要安装(外部)Maven。

  • 不需要特殊的m2e配置



解决方案是:




  • 打开eclipse。

  • 恢复m2e原始首选项(如果您更改任何一个):单击菜单:窗口>首选项> Maven>恢复默认值。对Maven项下的所有树项执行相同操作:原型,发现,错误/警告,安装,生命周期映射,模板,用户界面,用户设置。点击确定按钮。

  • 将用户设置文件的路径复制(例如记事本窗口)。要查看路径,请再次单击菜单:窗口>首选项> Maven>用户设置,路径位于用户设置文本框中。您将不得不手动编写路径,因为它不可复制和粘贴。在将路径应用到记事本之后,请勿关闭首选项窗口。

  • 在已打开的首选项窗口中,单击打开文件链接。关闭首选项窗口,您将看到已经在Eclipse编辑器中打开的settings.xml文件。

  • 编辑器将在底部有2个选项卡:设计和源。点击源选项卡。您将看到所有源代码(xml)。

  • 删除所有源代码:点击代码,按控制+ a,按del。

  • 将以下代码复制到编辑器(并自定义上限值):




 <设置> 
<代理>
<代理>
< active> true< / active>
< protocol> http< / protocol>
< host> YOUR.PROXY.IP.OR.NAME< / host>
< port>您的PROXY PORT< / port>
< username>您的PROXY USERNAME(如果不需要,则为空)< / username>
< password>您的代码密码(如果不需要,则为空)< / password>
< nonProxyHosts>您的代码排除主机列表(或空)< / nonProxyHosts>
< / proxy>
< /代理>
< / settings>





  • 保存文件:control +

  • 退出Eclipse:菜单文件>退出

  • 在Windows资源管理器中打开您复制的路径(不包含文件名,目录)。

  • 您可以查看xml文件(settings.xml)和directoy(repository)。删除directoy(存储库):右键单击>删除>是。

  • 启动Eclipse。

  • 现在,您将能够创建一个maven项目:文件>新建>其他> Maven> Maven项目>下一步>接下来,选择Catalog:All catalogs和Filter:maven-archetype-quickstart,点击搜索结果,然后点击按钮下一步,输入Group Id :test_gr和Artifact Id:test_art,点击完成按钮。



最后,我想给一个建议到m2e开发人员,使配置更容易。从互联网(从存储库)安装m2e后,m2e应检查Eclipse是否正在使用代理(首选项>常规>网络连接)。如果Eclipse正在使用代理,m2e应该向用户显示一个对话框:

  m2e已经检测到Eclipse正在使用代理访问互联网。 
您要我为嵌入式
Maven软件创建一个用户设置文件(settings.xml)吗?

[是] [否]

如果用户点击是,那么m2e应该通过从Eclipse首选项复制代理值来自动创建settings.xml文件。


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 following error:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.

Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE

Failed to resolve version for org.apache.maven.archetypes:maven-archetype- quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\xxxx.m2\repository)

Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\xxxx.m2\repository)

Proxy details are configured in .m2/settings.xml and generating a maven project from an archtype works fine in command line.

I tried to apply the solutions from here but none worked. The remote catalog is not acessible as well. I reckon it's a problem with the network settings of Eclipse. I also looked at this bug report to try and find some clues and couldn't really understand how to implement the workaround.

here is my settings.xml file:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>nexus</id>
            <username>xxxx@xxxx.com</username>
            <password>{XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}</password>
        </server>
        <server>
            <id>deployment</id>
            <username>xxxx@xxxx.com</username>
            <password>{XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}</password>
        </server>
    </servers>
    <mirrors>
        <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>https://nexus-int.xxxx.xxxx.com/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
        <id>nexus</id>
            <!--Enable snapshots for the built in central repo to direct -->
        <!--all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

Any ideas?

Thanks

Tomer

解决方案

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.

这篇关于不能在eclipse中创建Maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆