Maven不能解析依赖项,工件不能解析

时间:2023-01-26 21:15:42

This is supposed to be a working project from my friend. He demonstrated the project right in front of me, and then I copied the project, imported it as an existing maven project (I'm using m2eclipse plugin).

这应该是我朋友的工作项目。他在我面前演示了这个项目,然后我复制了这个项目,将它作为一个现有的maven项目导入(我正在使用m2eclipse插件)。

And then, this error occurs. This error can be reproduced every time I try to build something with maven.

然后,这个错误发生了。每次我尝试用maven构建东西时,都可以复制这个错误。

Doing mvn dependency:tree, dependency:list, or the usual build package, will result in the same error.

执行mvn依赖项:树、依赖项:列表或通常的构建包将导致相同的错误。

The error from running the 'package' build from eclipse is:

从eclipse运行“包”构建的错误是:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Jackpot Portal Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for javax.servlet:com.springsource.javax.servlet:jar:2.5.0 is missing, no dependency information available
[WARNING] The POM for javax.servlet:com.springsource.javax.servlet.jsp.jstl:jar:1.2.0 is missing, no dependency information available
[WARNING] The POM for javax.transaction:com.springsource.javax.transaction:jar:1.1.0 is missing, no dependency information available
[WARNING] The POM for org.slf4j:com.springsource.slf4j.log4j:jar:1.5.6 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.963s
[INFO] Finished at: Tue Jan 11 01:55:41 WIT 2011
[INFO] Final Memory: 2M/56M
[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal on project jackpot: Could not resolve dependencies 
for project com.jeteo:jackpot:war:1.0-SNAPSHOT: The following artifacts could 
not be resolved: javax.servlet:com.springsource.javax.servlet:jar:2.5.0,
javax.servlet:com.springsource.javax.servlet.jsp.jstl:jar:1.2.0, 
javax.transaction:com.springsource.javax.transaction:jar:1.1.0, 
org.slf4j:com.springsource.slf4j.log4j:jar:1.5.6: Failure to find 
javax.servlet:com.springsource.javax.servlet:jar:2.5.0 in 
http://repository.springsource.com/maven/bundles/release was cached in the 
local repository, resolution will not be reattempted until the update 
interval of com.springsource.repository.bundles.release has elapsed or 
updates are forced -> [Help 1]

[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

And here is the content of the pom.xml :

这是pom的内容。xml:

 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.jeteo</groupId>
 <artifactId>jackpot</artifactId>
 <packaging>war</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>Jackpot Portal Webapp</name>
 <url>http://www.jeteo.com</url>
 <properties>
  <java-version>1.6</java-version>
  <org.springframework-version>3.0.3.RELEASE</org.springframework-version>
  <org.hibernate-version>3.6.0.Final</org.hibernate-version>
  <org.aspectj-version>1.6.9</org.aspectj-version>
  <org.slf4j-version>1.5.10</org.slf4j-version>
 </properties>
 <dependencies>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</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-test</artifactId>
      <version>${org.springframework-version}</version>
  </dependency>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.8.1</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>net.sf.jt400</groupId>
   <artifactId>jt400</artifactId>
   <version>6.6</version>
   <scope>compile</scope>
  </dependency>

  <!-- Hibernate -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>${org.hibernate-version}</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${org.hibernate-version}</version>
            <scope>compile</scope>
        </dependency>

  <!-- AspectJ -->
  <dependency>
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjrt</artifactId>
   <version>${org.aspectj-version}</version>
  </dependency>
  <dependency>
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjtools</artifactId>
   <version>${org.aspectj-version}</version>
  </dependency>

  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>com.springsource.javax.servlet</artifactId>
   <version>2.5.0</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>com.springsource.javax.servlet.jsp.jstl</artifactId>
   <version>1.2.0</version>
   <scope>provided</scope>
  </dependency>
  <!--
  <dependency>
   <groupId>javax.persistence</groupId>
   <artifactId>com.springsource.javax.persistence</artifactId>
   <version>1.0.0</version>
   <scope>compile</scope>
  </dependency>
  -->
  <dependency>
   <groupId>javax.transaction</groupId>
   <artifactId>com.springsource.javax.transaction</artifactId>
   <version>1.1.0</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>1.5.6</version>
  </dependency>
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>com.springsource.slf4j.log4j</artifactId>
   <version>1.5.6</version>
  </dependency>
  <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.11</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

 </dependencies>
 <repositories>
  <!-- Spring releases -->
  <repository>
   <id>com.springsource.repository.bundles.release</id>
   <name>Spring Maven Repository Repository</name>
   <url>http://repository.springsource.com/maven/bundles/release</url>
  </repository>
  <!-- For hibernate 3.6 support -->
  <repository>
   <id>jboss</id>
   <url>https://repository.jboss.org/nexus/content/groups/public/</url>
  </repository>
 </repositories>
 <build>
  <finalName>jackpot</finalName>
  <plugins>
   <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>tomcat-maven-plugin</artifactId>
          <version>1.1</version>
          <configuration>
           <url>http://localhost:8080/manager</url>
          </configuration>
      </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
     <source>1.6</source>
     <target>1.6</target>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

I've tried downloading the newest version of maven, and included it in the eclipse helios, but still the same problem. The same error message happens even when I run it it in the shell command line (outside eclipse).

我已经尝试下载最新版本的maven,并将其包含在eclipse helios中,但仍然存在相同的问题。即使我在shell命令行(eclipse之外)运行它,也会发生相同的错误消息。

What am I missing?

我缺少什么?

11 个解决方案

#1


72  

Looks like you are missing some Maven repos. Ask for your friend's .m2/settings.xml, and you'll probably want to update the POM to include the repositories there.

看起来你漏掉了一些Maven的repos。询问你朋友的。m2/设置。您可能希望更新POM以包含那里的存储库。

--edit: after some quick googling, try adding this to your POM:

——编辑:在谷歌上搜索一下之后,试着把这个添加到你的POM中:

<repository>
    <id>com.springsource.repository.bundles.release</id>
    <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
    <id>com.springsource.repository.bundles.external</id>
    <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/external</url>
</repository>

#2


11  

Maven kept your files on cache, and don't retry to download them. You simply can manually 'help' him by deleteing the .m2 directory, and then our friend will download everything over the old depedencies.

Maven将您的文件保存在缓存中,并且不要重试下载它们。您可以通过删除.m2目录来手动“帮助”他,然后我们的朋友将在以前的depec上下载所有内容。

#3


5  

As an alternative source to the same problem, this answer cites using Maven 3 versus Maven 2 as the potential cause of this issue. Near as I can tell, this is due to changes in local repository resolution that was changed in Maven 3. Putting this here in case anyone else googles for it and reaches this answer (as I did).

作为相同问题的替代源,这个答案引用Maven 3和Maven 2作为这个问题的潜在原因。正如我所知道的,这是由于Maven 3中修改了本地存储库解析。把这个放在这里,以防其他人用谷歌搜索并得到这个答案(就像我一样)。

#4


3  

The artifactId for all the dependencies that failed to download are incorrect - for some reason they are prefixed with com.springsource. Cut/paste issue?

未能下载的所有依赖项的artifactId都是不正确的——出于某种原因,它们以com.springsource作为前缀。剪切/粘贴的问题?

You can try replacing them as follows.

你可以试着用下面的方法替换它们。

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.6</version>
        </dependency>

You may also want to add the maven central repository for these artifacts in case they are not available in the specified repositories.

您可能还想为这些工件添加maven中心存储库,以防它们在指定的存储库中不可用。

  <repository>
   <id>maven2</id>
   <url>http://repo1.maven.org/maven2</url>
  </repository>

#5


3  

I have had similar problem and I fixed it by adding the below repos in my pom.xml:

我遇到过类似的问题,我在我的pom.xml中添加了以下repos:

    <repository>
        <id>org.springframework.maven.release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://repo.springsource.org/libs-release-local</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>false</enabled></snapshots>
    </repository>
    <!-- For testing against latest Spring snapshots -->
    <repository>
        <id>org.springframework.maven.snapshot</id>
        <name>Spring Maven Snapshot Repository</name>
        <url>http://repo.springsource.org/libs-snapshot-local</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
    <!-- For developing against latest Spring milestones -->
    <repository>
        <id>org.springframework.maven.milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://repo.springsource.org/libs-milestone-local</url>
        <snapshots><enabled>false</enabled></snapshots>
    </repository>

#6


1  

I've got a similar message and my problem were some proxy preferences in my settings.xml. So i disabled them and everything works fine.

我有一个类似的消息,我的问题是在我的settings.xml中有一些代理首选项。所以我禁用了它们,一切都很好。

#7


0  

I had this problem. In my case it was caused by IntelliJ Idea messing around with some of the pom.xml files (which it seems to enjoy doing!). I just reverted to the original copy and things worked again!

我有这个问题。在我的例子中,是IntelliJ Idea搞乱了一些pom。xml文件(它似乎很喜欢这样做!)我又恢复了原来的版本,一切又恢复正常了!

#8


0  

I had this problem as well, it turned out it was because of NetBeans adding something to my pom.xml file. Double check nothing was added since previous successful deployments.

我也有这个问题,原来是因为NetBeans给我的pom添加了一些东西。xml文件。再次检查自以前成功部署以来没有添加任何内容。

#9


0  

My EAR project had 2 modules *.ear and *.war and I got this dependency error on *.war project when trying mvn eclipse:eclipse. Resolved it by fixing utf-8 encoding issue in the *.war project. mvn -X or -e options weren't of help here.

我的EAR项目有两个模块*。耳朵和*。war和我得到了依赖错误*。尝试mvn eclipse时的war项目:eclipse。通过在*中修复utf-8编码问题解决了这个问题。战争的项目。mvn -X或-e选项在这里没有帮助。

#10


0  

This kind of problems are caused by two reasons:

这类问题的产生有两个原因:

  1. the spell of a dependency is wrong
  2. 依赖的咒语是错误的
  3. the config of mvn setting (ie. ~/.m2/settings.xml) is wrong
  4. mvn设置的配置。~ / .m2 / settings.xml)是错误的

If most of dependencies can be downloaded, then the reason 1 may be the most likely bug. On the contrary, if most of dependencies have the problem, then u should take a look at settings.xml.

如果可以下载大部分依赖项,那么原因1可能是最有可能的bug。相反,如果大多数依赖项都有问题,那么您应该看看settings.xml。

Well, I have tried to fix my problem the whole afternoon, and finally I got it. My problem occurs in settings.xml, not the lose or wrong spelling of settings.xml, but the lose of activeProfiles.

我整个下午都在努力解决我的问题,最后我终于解决了。我的问题出现在设置中。xml,而不是设置的丢失或错误拼写。xml,但丢失了activeProfiles。

#11


0  

Download the jar manually and then execute the command from the folder where the jar is saved:

手动下载jar,然后从保存jar的文件夹执行命令:

mvn install:install-file -Dfile=jar_file_name.jar-DgroupId=group_id -DartifactId=artifact_id -Dversion=version_no -Dpackaging=jar

mvn安装:安装文件-Dfile = jar_file_name。jar-DgroupId = group_id -DartifactId = artifact_id -Dversion = version_no -Dpackaging = jar

The jar file, jar_file_name, group_id, artifact_id and version_no are available from the maven repository page.

jar文件、jar_file_name、group_id、artifact_id和version_no都可以从maven存储库页面获得。

happy coding :)

编码快乐:)

#1


72  

Looks like you are missing some Maven repos. Ask for your friend's .m2/settings.xml, and you'll probably want to update the POM to include the repositories there.

看起来你漏掉了一些Maven的repos。询问你朋友的。m2/设置。您可能希望更新POM以包含那里的存储库。

--edit: after some quick googling, try adding this to your POM:

——编辑:在谷歌上搜索一下之后,试着把这个添加到你的POM中:

<repository>
    <id>com.springsource.repository.bundles.release</id>
    <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
    <id>com.springsource.repository.bundles.external</id>
    <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/external</url>
</repository>

#2


11  

Maven kept your files on cache, and don't retry to download them. You simply can manually 'help' him by deleteing the .m2 directory, and then our friend will download everything over the old depedencies.

Maven将您的文件保存在缓存中,并且不要重试下载它们。您可以通过删除.m2目录来手动“帮助”他,然后我们的朋友将在以前的depec上下载所有内容。

#3


5  

As an alternative source to the same problem, this answer cites using Maven 3 versus Maven 2 as the potential cause of this issue. Near as I can tell, this is due to changes in local repository resolution that was changed in Maven 3. Putting this here in case anyone else googles for it and reaches this answer (as I did).

作为相同问题的替代源,这个答案引用Maven 3和Maven 2作为这个问题的潜在原因。正如我所知道的,这是由于Maven 3中修改了本地存储库解析。把这个放在这里,以防其他人用谷歌搜索并得到这个答案(就像我一样)。

#4


3  

The artifactId for all the dependencies that failed to download are incorrect - for some reason they are prefixed with com.springsource. Cut/paste issue?

未能下载的所有依赖项的artifactId都是不正确的——出于某种原因,它们以com.springsource作为前缀。剪切/粘贴的问题?

You can try replacing them as follows.

你可以试着用下面的方法替换它们。

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.6</version>
        </dependency>

You may also want to add the maven central repository for these artifacts in case they are not available in the specified repositories.

您可能还想为这些工件添加maven中心存储库,以防它们在指定的存储库中不可用。

  <repository>
   <id>maven2</id>
   <url>http://repo1.maven.org/maven2</url>
  </repository>

#5


3  

I have had similar problem and I fixed it by adding the below repos in my pom.xml:

我遇到过类似的问题,我在我的pom.xml中添加了以下repos:

    <repository>
        <id>org.springframework.maven.release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://repo.springsource.org/libs-release-local</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>false</enabled></snapshots>
    </repository>
    <!-- For testing against latest Spring snapshots -->
    <repository>
        <id>org.springframework.maven.snapshot</id>
        <name>Spring Maven Snapshot Repository</name>
        <url>http://repo.springsource.org/libs-snapshot-local</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
    <!-- For developing against latest Spring milestones -->
    <repository>
        <id>org.springframework.maven.milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://repo.springsource.org/libs-milestone-local</url>
        <snapshots><enabled>false</enabled></snapshots>
    </repository>

#6


1  

I've got a similar message and my problem were some proxy preferences in my settings.xml. So i disabled them and everything works fine.

我有一个类似的消息,我的问题是在我的settings.xml中有一些代理首选项。所以我禁用了它们,一切都很好。

#7


0  

I had this problem. In my case it was caused by IntelliJ Idea messing around with some of the pom.xml files (which it seems to enjoy doing!). I just reverted to the original copy and things worked again!

我有这个问题。在我的例子中,是IntelliJ Idea搞乱了一些pom。xml文件(它似乎很喜欢这样做!)我又恢复了原来的版本,一切又恢复正常了!

#8


0  

I had this problem as well, it turned out it was because of NetBeans adding something to my pom.xml file. Double check nothing was added since previous successful deployments.

我也有这个问题,原来是因为NetBeans给我的pom添加了一些东西。xml文件。再次检查自以前成功部署以来没有添加任何内容。

#9


0  

My EAR project had 2 modules *.ear and *.war and I got this dependency error on *.war project when trying mvn eclipse:eclipse. Resolved it by fixing utf-8 encoding issue in the *.war project. mvn -X or -e options weren't of help here.

我的EAR项目有两个模块*。耳朵和*。war和我得到了依赖错误*。尝试mvn eclipse时的war项目:eclipse。通过在*中修复utf-8编码问题解决了这个问题。战争的项目。mvn -X或-e选项在这里没有帮助。

#10


0  

This kind of problems are caused by two reasons:

这类问题的产生有两个原因:

  1. the spell of a dependency is wrong
  2. 依赖的咒语是错误的
  3. the config of mvn setting (ie. ~/.m2/settings.xml) is wrong
  4. mvn设置的配置。~ / .m2 / settings.xml)是错误的

If most of dependencies can be downloaded, then the reason 1 may be the most likely bug. On the contrary, if most of dependencies have the problem, then u should take a look at settings.xml.

如果可以下载大部分依赖项,那么原因1可能是最有可能的bug。相反,如果大多数依赖项都有问题,那么您应该看看settings.xml。

Well, I have tried to fix my problem the whole afternoon, and finally I got it. My problem occurs in settings.xml, not the lose or wrong spelling of settings.xml, but the lose of activeProfiles.

我整个下午都在努力解决我的问题,最后我终于解决了。我的问题出现在设置中。xml,而不是设置的丢失或错误拼写。xml,但丢失了activeProfiles。

#11


0  

Download the jar manually and then execute the command from the folder where the jar is saved:

手动下载jar,然后从保存jar的文件夹执行命令:

mvn install:install-file -Dfile=jar_file_name.jar-DgroupId=group_id -DartifactId=artifact_id -Dversion=version_no -Dpackaging=jar

mvn安装:安装文件-Dfile = jar_file_name。jar-DgroupId = group_id -DartifactId = artifact_id -Dversion = version_no -Dpackaging = jar

The jar file, jar_file_name, group_id, artifact_id and version_no are available from the maven repository page.

jar文件、jar_file_name、group_id、artifact_id和version_no都可以从maven存储库页面获得。

happy coding :)

编码快乐:)