Maven build error

自古美人都是妖i 提交于 2019-12-10 19:04:43

问题


I want to build a spring mvc project by maven,I got the following error:

The following artifacts could not be resolved: org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0, org.hibernate:hibernate-validator:jar:4.2.0.Beta1: Could not find artifact org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0 in central (http://repo1.maven.org/maven2)

I use eclipse and m2eclipse plugin. I don't know how to add local repository. And I found for different versions of eclipse,the result is different. Some can pass, some fail.I am confused.

By the way where can I find the version of maven used in m2eclipse?

Thanks in advanced.

Update:Now I can handle hibernate-validator,but even I deleted all spring mvc dependencies,I found there are many other library are dependent on com.springsource.org.aopalliance,


回答1:


Since you are working with spring artifacts, you can refer to this doc. If you are working on released versions of spring, you can add the following repository in your settings.xml

   <repository>
      <id>com.springsource.repository.maven.release</id>
      <url>http://maven.springframework.org/release/</url>
      <snapshots>
          <enabled>false</enabled>
       </snapshots>
   </repository>

[Edit 1: based on the comment]

The groupId/projectId of aopalliance seems to indicate it is in spring enterprise bundle repository. The contents of this accessible from the following repository url.

<url>http://repository.springsource.com/maven/bundles/release/</url>

As for hibernate-validator, being a beta release, it is possibly not available in the normal repos. It is available from

<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>



回答2:


Check your %.m2\repository\org\aopalliance\com.springsource.org.aopalliance\1.0.0\. If there isn't a com.springsource.org.aopalliance-1.0.0.jar in there, just download it by yourself and copy it to this folder.




回答3:


The version of maven used in m2eclipse can be found in Window->Preferences->Maven->Installations

It looks like the artifact cann't be found in any repository you have defined in your settings.xml or pom file. Try adding sonatype repositories, they have artifacts you're looking for

In your pom.xml , add :

  <project>
  ...
  <repositories>
    <repository>
      <id>sonatype repo</id>
      <url>https://repository.sonatype.org/content/repositories/central</url>
    </repository>
  </repositories>
  ...
</project>

However it's good practice to have its own repository manager (nexus, archiva, ...)




回答4:


You should add the "external" repository to your pom.xml:

<repository>
    <id>com.springsource.repository.bundles.external</id>
    <url>http://repository.springsource.com/maven/bundles/external</url>
</repository>

My complete repositories tag in pom.xml is as follows:

<repositories>
    <repository>
        <id>com.springsource.repository.maven.release</id>
        <url>http://repo.springsource.org/release/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
</repositories>


来源:https://stackoverflow.com/questions/5216794/maven-build-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!