146

从现在到那时,我的 Maven 2 开始乱七八糟。

我正在使用 SPring STS 2.6.1 并且有一个基于 Spring 3、Hibernate、DWR、Cometd 和所有这些东西的项目。

今天我刚从 Git 更新,突然间,mvn我的项目旁边出现了那个可怕的感叹号(!)。

点击“项目 - > Maven - > 更新依赖项”后,我收到:

24.05.11 15:26:58 MESZ: Missing artifact org.jdom:jdom:jar:1.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-common:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-core:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-solrj:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact stax:stax:jar:1.2.0:compile
24.05.11 15:26:58 MESZ: Missing artifact stax:stax-api:jar:1.0.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-analyzers:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-core:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-highlighter:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-queries:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-snowball:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-lucene-spellchecker:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-httpclient:commons-httpclient:jar:3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.commons:commons-io:jar:1.3.2:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-logging:commons-logging:jar:1.0.4:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.solr:solr-commons-csv:jar:1.3.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
24.05.11 15:26:58 MESZ: Missing artifact net.java.dev.stax-utils:stax-utils:jar:20040917:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.lucene:lucene-snowball:jar:2.4.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.lucene:lucene-core:jar:2.4.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.slf4j:slf4j-api:jar:1.6.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-core:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact aopalliance:aopalliance:jar:1.0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-aspects:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-test:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-context:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-oxm:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-web:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework:spring-instrument:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-core:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-web:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-taglibs:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-acl:jar:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-parent:pom:3.0.5.RELEASE:compile
24.05.11 15:26:58 MESZ: Missing artifact org.springframework.security:spring-security-config:jar:3.0.5.RELEASE:system
24.05.11 15:26:58 MESZ: Missing artifact org.hibernate:hibernate-core:jar:3.3.2.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact antlr:antlr:jar:2.7.6:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-collections:commons-collections:jar:3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact dom4j:dom4j:jar:1.6.1:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.transaction:jta:jar:1.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact org.hibernate:ejb3-persistence:pom:1.0.2.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-dbcp:commons-dbcp:jar:1.4:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-pool:commons-pool:jar:1.5.4:compile
24.05.11 15:26:58 MESZ: Missing artifact org.aspectj:aspectjweaver:jar:1.6.10:compile
24.05.11 15:26:58 MESZ: Missing artifact org.slf4j:slf4j-log4j12:jar:1.6.1:compile
24.05.11 15:26:58 MESZ: Missing artifact log4j:log4j:jar:1.2.16:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.persistence:persistence-api:jar:1.0:compile
24.05.11 15:26:58 MESZ: Missing artifact javassist:javassist:jar:3.12.1.GA:compile
24.05.11 15:26:58 MESZ: Missing artifact postgresql:postgresql:jar:9.0-801.jdbc4:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-codec:commons-codec:jar:1.4:compile
24.05.11 15:26:58 MESZ: Missing artifact org.directwebremoting:dwr:jar:2.0.3:compile
24.05.11 15:26:58 MESZ: Missing artifact org.beanshell:bsh:jar:2.0b4:compile
24.05.11 15:26:58 MESZ: Missing artifact org.jasypt:jasypt:jar:1.7:compile
24.05.11 15:26:58 MESZ: Missing artifact cglib:cglib:jar:2.2:compile
24.05.11 15:26:58 MESZ: Missing artifact asm:asm:jar:3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-fileupload:commons-fileupload:jar:1.2.2:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.poi:poi:jar:3.8-beta1:compile
24.05.11 15:26:58 MESZ: Missing artifact jasperreports:jasperreports:jar:3.5.3:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-beanutils:commons-beanutils:jar:1.8.0:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-digester:commons-digester:jar:1.7:compile
24.05.11 15:26:58 MESZ: Missing artifact jfree:jcommon:jar:1.0.15:compile
24.05.11 15:26:58 MESZ: Missing artifact jfree:jfreechart:jar:1.0.12:compile
24.05.11 15:26:58 MESZ: Missing artifact xml-apis:xml-apis:jar:1.3.02:compile
24.05.11 15:26:58 MESZ: Missing artifact eclipse:jdtcore:jar:3.1.0:compile
24.05.11 15:26:58 MESZ: Missing artifact junit:junit:jar:4.8.2:test
24.05.11 15:26:58 MESZ: Missing artifact org.easymock:easymock:jar:3.0:test
24.05.11 15:26:58 MESZ: Missing artifact cglib:cglib-nodep:jar:2.2:test
24.05.11 15:26:58 MESZ: Missing artifact org.objenesis:objenesis:jar:1.2:test
24.05.11 15:26:58 MESZ: Missing artifact net.sf.ehcache:ehcache:pom:2.3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact net.sf.ehcache:ehcache-core:jar:2.3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact net.sf.ehcache:ehcache-terracotta:jar:2.3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.opensymphony.quartz:quartz-all:jar:1.6.1:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.servlet:jstl:jar:1.1.2:compile
24.05.11 15:26:58 MESZ: Missing artifact taglibs:standard:jar:1.1.2:compile
24.05.11 15:26:58 MESZ: Missing artifact org.aspectj:aspectjrt:jar:1.6.5:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.velocity:velocity:jar:1.6.2:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-lang:commons-lang:jar:2.4:compile
24.05.11 15:26:58 MESZ: Missing artifact oro:oro:jar:2.0.8:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.mail:mail:jar:1.4.1:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.activation:activation:jar:1.1:compile
24.05.11 15:26:58 MESZ: Missing artifact com.lowagie:itext:jar:2.0.7:compile
24.05.11 15:26:58 MESZ: Missing artifact bouncycastle:bcmail-jdk14:jar:138:compile
24.05.11 15:26:58 MESZ: Missing artifact bouncycastle:bcprov-jdk14:jar:138:compile
24.05.11 15:26:58 MESZ: Missing artifact org.cometd.java:cometd-java-server:jar:1.0.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.cometd.java:cometd-api:jar:1.0.1:compile
24.05.11 15:26:58 MESZ: Missing artifact org.eclipse.jetty:jetty-util:jar:7.0.1.v20091125:compile
24.05.11 15:26:58 MESZ: Missing artifact org.eclipse.jetty:jetty-continuation:jar:7.0.1.v20091125:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.velocity:velocity-tools:jar:2.0:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-chain:commons-chain:jar:1.1:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-validator:commons-validator:jar:1.3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact sslext:sslext:jar:1.2-0:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.struts:struts-core:jar:1.3.8:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.struts:struts-taglib:jar:1.3.8:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.struts:struts-tiles:jar:1.3.8:compile
24.05.11 15:26:58 MESZ: Missing artifact net.htmlparser.jericho:jericho-html:jar:3.1:compile
24.05.11 15:26:58 MESZ: Missing artifact ro.isdc.wro4j:wro4j-core:jar:1.3.3:compile
24.05.11 15:26:58 MESZ: Missing artifact commons-io:commons-io:jar:2.0:compile
24.05.11 15:26:58 MESZ: Missing artifact com.google.collections:google-collections:jar:1.0:compile
24.05.11 15:26:58 MESZ: Missing artifact javax.servlet:servlet-api:jar:2.5:compile
24.05.11 15:26:58 MESZ: Missing artifact redis.clients:jedis:jar:1.5.2:compile
24.05.11 15:26:58 MESZ: Missing artifact org.mongodb:mongo-java-driver:jar:2.5.2:compile
24.05.11 15:26:58 MESZ: Missing artifact org.xhtmlrenderer:core-renderer:jar:R8pre2:compile
24.05.11 15:26:58 MESZ: Missing artifact org.apache.sanselan:sanselan:jar:0.97-incubator:compile
24.05.11 15:26:58 MESZ: Missing artifact com.kenai.nbpwr:com-sun-pdfview:jar:1.0.5-201003191900:compile
24.05.11 15:26:58 MESZ: Missing artifact org.swinglabs:pdf-renderer:jar:1.0.5:compile
24.05.11 15:26:58 MESZ: Missing artifact org.safehaus.jug:jug:jar:2.0.0:system
24.05.11 15:26:58 MESZ: Missing artifact de.dankomannhaupt:JDBCAppender:jar:1.0:system
24.05.11 15:26:58 MESZ: Missing artifact spy:memcahed:jar:2.5:system
24.05.11 15:26:58 MESZ: Missing artifact net.sf.beanlib:beanlib:jar:5.0.2beta:compile
24.05.11 15:26:58 MESZ: Missing artifact xstream:xstream:jar:1.1.2:compile
24.05.11 15:26:58 MESZ: Missing artifact net.jcip:jcip-annotations:jar:1.0:compile
24.05.11 15:26:58 MESZ: Missing artifact net.sf.beanlib:beanlib-hibernate:jar:5.0.2beta:compile

我的pom.xml样子:

<properties>
        <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
        <hibernate.version>3.3.2.GA</hibernate.version>
    </properties>

    <repositories>
        <repository>
            <id>JBoss</id>
            <name>JBoss Repsitory</name>
            <layout>default</layout>
            <url>http://repository.jboss.org/maven2</url>
        </repository>
    </repositories>
    <!-- Bezeichnung -->
    <artifactId>project-dao</artifactId>
    <name>Vevention Dao</name>
    <groupId>com.corp.dao</groupId>
    <version>1.0Beta</version>

    <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-expression</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-beans</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-aop</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-aspects</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context-support</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-oxm</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>${org.springframework.version}</version>
        </dependency>
        <dependency> 
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${org.springframework.version}</version>
         </dependency>
         <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.version}</version>
         </dependency>
         <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${org.springframework.version}</version>
         </dependency>
        <dependency> 
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.version}</version>
            <scope>system</scope> 
            <systemPath>${basedir}/lib/spring-security-config-3.0.5.RELEASE.jar</systemPath> 
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>         

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>ejb3-persistence</artifactId>
            <version>1.0.2.GA</version>
            <type>pom</type>
        </dependency>
<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search</artifactId>
            <version>3.1.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-common</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-core</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-snowball</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.0.1B</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>2.5.6.SEC01</version>
        </dependency>
        <dependency>
            <groupId>memcached</groupId>
            <artifactId>memcached</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.5</version>
        </dependency>
         <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>1.5.2</version>
        </dependency>       

        <dependency>
            <groupId>voldemort</groupId>
            <artifactId>voldemort</artifactId>
            <version>0.81</version>
        </dependency>

    </dependencies>
</project>

然后我检查了我的 Mac /Users/XYZ/.m2,所有 jar 文件都按预期到位。

我正在使用 STS 附带的当前 Maven 版本。我还启用了调试输出,但没有任何可疑之处。

4

34 回答 34

209

除了Project -> Clean之外,还有一些其他选项,其中一些更类似于将其关闭和再次打开。

  • 尝试右键单击项目并选择Maven -> Update Project Configuration
  • 禁用然后重新启用依赖管理(右键单击Maven ->禁用依赖管理然后Maven ->启用依赖管理
  • 关闭项目并重新打开它。
  • 检查您的 Maven 设置是否配置正确。如果您使用代理,则需要在全局或用户设置中配置代理设置。
  • 检查您正在使用您期望的 Maven 安装。默认情况下 m2eclipse 使用嵌入器,如果您有单独的安装,您可能希望将m2eclipse 配置为使用外部安装,以便 CLI 和 Eclipse 构建是一致的。这也确保您已配置为通过上述任何代理进行连接。
于 2011-05-24T14:48:48.270 回答
62

我在 SpringSource Tools ver 2.8.0.RELEASE 上收到了同样的问题。我必须执行 Maven -> Update Maven Dependencies 并检查“强制更新快照/发布”选项。

于 2011-11-18T17:35:25.607 回答
54

我遇到了类似的问题。缺少的工件(jar 文件)存在于 ~/.m2 目录中,并且不知何故 eclipse 无法找到它。

例如:缺少工件 org.jdom:jdom:jar:1.1:compile

我查看了这个目录~/.m2/repository/org/jdom/jdom/1.1,我注意到有这个文件_maven.repositories。我使用文本编辑器打开它并看到以下条目:

#NOTE: This is an internal implementation file, its format can be changed without prior notice.
#Wed Feb 13 17:12:29 SGT 2013
jdom-1.1.jar>central=
jdom-1.1.pom>central=

我只是从文件中删除了“中心”字:

#NOTE: This is an internal implementation file, its format can be changed without prior notice.
#Wed Feb 13 17:12:29 SGT 2013
jdom-1.1.jar>=
jdom-1.1.pom>=

并从 eclipse 运行 Maven > Update Project 并且它刚刚工作:) 请注意,您的文件可能包含其他关键字而不是“central”。

于 2013-06-27T17:58:17.893 回答
25

我有同样的问题。Rich Seller 的解决方案不适用于我的情况,我通过取消Window -> Preferences -> Maven. Do not automatically update dependencies from remote repositories选项,然后右键单击项目并选择Maven->Update Project.

于 2012-08-01T06:43:47.173 回答
14

我有类似的问题。它显示错误“缺少工件......”。深入研究后,我发现我启用了代理设置,应该在 Maven 的 conf 文件夹中的 setting.xml 中配置(代理名称、用户/密码)。作为解决方案,请转到 Eclipse.... Windows->preferences->Maven->UserSettings....并更新用户设置以指向您在 Maven 的 conf 文件夹中的 setting.xml。之后去Project->Update All Maven Dependencies。构建后它应该可以正常工作。

于 2011-10-31T09:52:34.153 回答
14

我在 Spring Boot 依赖项中遇到了同样的错误。为我解决的问题是让 Maven 解决使用依赖管理包装它们的依赖关系:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RELEASE</version>
</parent>

<dependencyManagement>
    <dependencies>
      <dependency>...</dependency>
      ...
    </dependencies>
</dependencyManagement>
于 2016-01-05T18:59:54.437 回答
8

哇,这让我把头发扯掉了,我的头撞到了墙壁、桌子和其他东西上。我遇到了与 OP 相同或类似的问题,它要么丢失/未下载 jar 文件或下载它们,但未将它们包含在 Maven 依赖项中并显示相同的错误消息。我对 java 打包和 maven 的有限知识可能没有帮助。

对我来说,问题似乎是由依赖类型“捆绑”引起的 (但我不知道如何或为什么)。我在 pom.xml 上使用 Eclipse Mars 中的 Add Dependency 对话框,它允许您搜索和浏览中央存储库。我正在搜索并添加对 jackson-core 库的依赖项,选择最新版本,以bundle的形式提供。这一直失败。

所以最后,我将依赖属性表单 bundle 更改为jar(再次使用依赖属性窗口),它最终在保存更改后正确下载并引用了依赖项。

于 2016-07-27T14:18:50.523 回答
4

最后,它被证明是一个缺失的 solr 工件,它似乎阻塞了我所有其余的构建周期。

我不知道为什么 mvn 会这样,但升级到最新版本修复了它。

于 2011-05-26T13:13:15.860 回答
3

M2Eclipse 有时会这样做。从菜单中选择Project > Clean ...,重建后一切都会好起来的

于 2011-05-24T13:51:25.243 回答
3

我有类似的问题。在添加以下依赖项之后

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.9.1</version>
    <type>bundle</type>
</dependency>

导致问题。我删除了那个依赖,即使我得到了同样的错误。我不知道发生了什么。我尝试更新解决了我的问题的 Maven 依赖项配置。

于 2012-10-26T06:40:55.713 回答
3

到目前为止,这里的任何答案都没有取得太大的成功。

我的解决方案:

我手动下载了 jar 文件,然后使用 Apache Maveninstall:install-file插件安装了依赖项,请在此处查看更多详细信息

一个完整的例子:

<dependency>
     <groupId>commons-net</groupId>
     <artifactId>commons-net</artifactId>
     <version>3.4</version>
</dependency>
  1. 从这里下载 jar 文件

  2. 使用以下命令安装它:

mvn -X install:install-file " -DgroupId=commons-net" "-DartifactId=commons-net" "-Dversion=3.4" "-Dpackaging=jar" "-Dfile={your_full_downloads_path}/commons-net-3.4.jar"

  1. 点击项目并选择Maven->Update Project
于 2016-04-01T20:11:59.087 回答
2

我下载丢失的 jar 并放置在 .m2 存储库中修复了问题 =]

于 2013-02-15T22:08:42.067 回答
2

我遇到了同样的问题,maven 抱怨缺少工件,即使它存在于 .m2/repository/[...] 中。就我而言,问题是我忘记在最初下载包的 pom.xml 中指定正确的存储库(由另一个项目下载)。

将包存储库添加到 pom.xml 解决了这个问题。

<repositories>
  <repository>
    <id>SomeName</id>
    <name>SomeName</name>
    <url>http://url.to.repo</url>
  </repository>
</repositories>

感谢Maximilianus对包目录中那些“*.repositories”文件的提示。

于 2016-03-17T10:58:38.923 回答
2

哦,真是一团糟!我的建议:当涉及到凌乱的 pom 或项目打包时,Eclipse 在显示真正的问题方面真的很糟糕。它会告诉您缺少一些依赖项,而事实上 pom 格式错误或您的 pom.xml 中存在其他问题。

让 Eclipse 单独运行 maven 安装。你会很快找到真正的问题!

于 2018-02-12T14:50:05.067 回答
1

正如我的朋友所说的那样,我在上面尝试了所有但实际上没有任何效果,我遇到了同样的问题并以不同的方式找到了解决方案,当我在存储库下面添加时我的问题开始了

<dependency>
  <groupId>dom4j</groupId>
  <artifactId>dom4j</artifactId>
  <version>20040902.021138</version>
</dependency>

我的问题开始了......所以我更改了版本并采用了以前的版本,它删除了所有错误。所以我认为这个问题可能是因为我们在 POM.xml 文件中添加的版本。

于 2012-08-23T00:19:34.373 回答
1

以下步骤对我有用。

1)从 pom.xml 文件中剪切所有内容并保留另一个文件并保存 pom.xml
2)只需删除 .m2 文件夹(整个 maven 存储库)并重新启动 eclipse(或 jbdevstudio)
3)粘贴以前的 pom.xml文件内容(来自剪切文件)并且所有错误都消失了。

于 2014-06-09T09:05:48.080 回答
1

我遇到了同样的问题,下面的步骤删除了所有这些错误:

  • 右键单击项目 -> Maven -> 更新项目
于 2015-06-25T09:13:52.877 回答
1

我在 pom.xml 中使用了以下代码来下载 jar

<dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.FINAL</version>
</dependency>

但是在验证文件夹下的 .m2 文件夹中...... jar 没有被下载。我不确定这个问题。但我从 maven 官方网站下载了相同的 jar 并放在相应文件夹下的 .m2 文件夹中并清理了项目。错误消失了,它现在开始工作了。

于 2016-03-22T12:00:16.390 回答
0

我的案例遵循程序解决了这个问题

1-在此处输入图像描述

2-检查活动配置文件 在此处输入图像描述

于 2014-08-21T07:01:58.877 回答
0

我几次遇到这个问题。以下解决方案对我有用。

  1. 复制现有的 pom 文件作为备份,并删除导致此错误的依赖项。删除该工件所引用的文件夹的内容。
  2. 再次在 pom 中添加已删除的依赖项,并在该文件夹中添加 jar 文件。
  3. 做一个Maven->更新项目。错误会消失。

附带说明一下,有时当您从其他计算机复​​制文件时,可能会有加密。

于 2015-02-24T09:19:06.720 回答
0

我有一个类似的解决方案,比如@maximilianus。不同之处在于我的 .repositories 文件被称为 _remote.repositores,我必须删除它们才能使其正常工作。

例如,在我的情况下,我删除了

  • C:\Users\USERNAME.m2\repository\jta\jta\1.0.1_remote.repositories 和
  • C:\Users\USERNAME.m2\repository\jndi\jndi\1.2.1_remote.repositories

这样做后,我的错误消失了。

于 2015-03-12T22:18:24.200 回答
0

我遇到了与 SBT 和 slf4j 类似的问题。什么都没有改变,但在一台机器上它突然无法构建。

我试过:

  • sbt 清洁
  • 删除target/
  • 删除项目工作目录并进行新的结帐/构建
  • 删除~/.sbt/<scala-version>/文件夹
  • ~/.ivy2从缓存中删除有问题的 slf4j 文件夹
  • 将丢失的 slf4j jar 放在预期的 ivy2 文件夹中

以上都没有奏效。

所以,我不得不硬着头皮删除我的整个~/.ivy2/缓存文件夹并等待 2GB 的依赖项再次下载。我不熟悉其中写入了哪种缓存清单,但这一定是其中之一的损坏。

(使用 SBT 2.10.4 进行 Spark 构建)

于 2015-10-18T16:41:26.307 回答
0

如果其他解决方案不起作用并且您知道正确的 jar 在您的存储库中,那么:

问题是eclipse出于某种原因缓存了错误。

我通过删除问题选项卡中的错误解决了这个问题,然后我刷新了项目资源管理器,所有的感叹号和错误都没有返回。

于 2016-01-05T19:39:59.100 回答
0

我看到了一个错误,表现为“安装工件时出错:文件../null/...不存在”(即,由于路径中有“null”,所以找不到文件)。原因是 Maven 看不到一个环境变量。它是:

JV_SRCROOT=$DIRECTORY

代替

export JV_SRCROOT=$DIRECTORY

(在后一种情况下,变量对子进程可见)

于 2017-07-05T15:20:16.857 回答
0

运行 eclipse:clean eclipse:eclipse 它对我有用。 在此处输入图像描述

于 2018-03-19T05:14:07.857 回答
0

只是为了提供另一种可能的解决方案:就我而言,我从 .m2/jdom/jdom/1.0 设置中删除了“中央”,然后做了其他所有事情,但没有结果。

所以我发现 ./m2 文件夹中的 settings.xml 被一个失败的进程卡住了。由于我在系统任务管理器中没有找到该进程,所以我重新启动了计算机并且它工作了。

于 2018-03-20T18:54:19.093 回答
0

如果对我来说没有其他工作,在问题视图中,右键单击并复制错误并将其粘贴到文本编辑器中。并向下滚动以查看除了缺少的工件之外是否还有其他错误。

Eclipse 问题视图仅显示大约 100 个错误,不可见的错误可能是导致所有其他缺失工件错误的错误。

一旦我看到所有错误,我就能够找出问题所在并修复它。

于 2018-07-20T17:19:07.900 回答
0

我尝试了很多技巧,但唯一有效的是这个。更新 Maven 配置。右键单击 pom.xml,运行方式 -> Maven 构建(第二个)。在目标字段中输入“干净的包”。选中跳过测试框。然后运行,它会正确下载所有的jar,问题就解决了。

于 2018-11-13T19:12:23.007 回答
0

除了在我的存储库中手动安装 jar 之外,我尝试了所有上述解决方案。

通过删除与“丢失的 jar 文件”相同的目录中的 _remote_repositories 文件并进行 maven 更新,我得到了它的工作。

我想这与手动安装的最终结果相同。

于 2019-01-31T11:42:29.200 回答
0

我的问题:我忘记将一个新添加的项目(由我的同事添加)导入我的 Eclipse 工作区。

File > Import > Maven > Existing Maven Projects,在 dir-tree 中找到它,检查未添加的单个 non-ghosted 项目。

详细信息:我的同事添加了一个新项目,它是一个 git 子模块。现有项目在他们的 pom.xml 中引用了它。我已经完成了“git submodule init”和“git submodule update”。mvn 从命令行构建得很好,但我在 Eclipse 中不断收到这个“缺少工件”错误,指向我的 pom.xml 的顶部。

于 2019-08-29T16:39:20.350 回答
0

上述解决方案都不适合我。

我不得不删除我所有的 Maven 本地存储库。右键单击项目 -> Maven -> 更新项目。并修复!!

于 2019-11-26T07:10:23.477 回答
0

当我从 maven 存储库复制时,第 4 行称为<type>. 当我删除它时<type>,它解决了我的错误。

于 2019-12-21T18:40:23.127 回答
0

我的情况是它的版本丢失了,我通过在 maven Central 中使用“spring-boot-starter-parent”版本搜索该软件包找到了

更改前:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.6</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

更改后:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.6</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>2.5.6</version>
        <scope>test</scope>
    </dependency>

刚刚将添加的父版本更改为缺少的依赖项

于 2021-11-10T12:33:44.850 回答
-1
sudo eclipse

对我来说,这个问题与@maximilianus 的问题有关——eclipse 无法在我的机器上找到工件。

原来我所要做的就是以超级用户身份运行 ubuntu,并且 eclipse 可以访问 /root/.m2/ 目录

(不确定这是一个好习惯,但它解决了我花了几个小时解决的问题)

编辑:这绝对不是一个好习惯,相反,我以普通用户而不是 root 身份重新设置了我的环境,并且效果很好!(学习 Linux)

于 2019-07-02T11:32:27.620 回答