2015-06-21 69 views
0

我正在研究一个组刚刚开始的Web应用程序,但我无法使其运行。使用手动下载的依赖关系的POM错误

我与STS(春季工具套件)的Java相当新手,和我一起的.jar文件手动安装所有的依赖。但是现在我的pom.xml显示了很多错误。我想有一种方法可以用Maven解决这个问题,但我不知道该怎么做。

这里是的pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    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>edu.isep</groupId> 
    <artifactId>easypark</artifactId> 
    <name>EasyPark</name> 
    <packaging>war</packaging> 
    <version>1.0.0-BUILD-SNAPSHOT</version> 
    <properties> 
     <java-version>1.6</java-version> 
     <org.springframework-version>3.1.1.RELEASE</org.springframework-version> 
     <org.aspectj-version>1.6.10</org.aspectj-version> 
     <org.slf4j-version>1.6.6</org.slf4j-version> 
    </properties> 
    <dependencies> 
     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>3.2.2.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${org.springframework-version}</version> 
      <exclusions> 
       <!-- Exclude Commons Logging in favor of SLF4j --> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 

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

     <!-- Logging --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${org.slf4j-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>jcl-over-slf4j</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.15</version> 
      <exclusions> 
       <exclusion> 
        <groupId>javax.mail</groupId> 
        <artifactId>mail</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>javax.jms</groupId> 
        <artifactId>jms</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jdmk</groupId> 
        <artifactId>jmxtools</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jmx</groupId> 
        <artifactId>jmxri</artifactId> 
       </exclusion> 
      </exclusions> 
      <scope>runtime</scope> 
     </dependency> 

     <!-- @Inject --> 
     <dependency> 
      <groupId>javax.inject</groupId> 
      <artifactId>javax.inject</artifactId> 
      <version>1</version> 
     </dependency> 

     <!-- BDD --> 

     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.35</version> 
     </dependency> 

     <!-- Servlet --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <!-- Test --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 

    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-eclipse-plugin</artifactId> 
       <version>2.9</version> 
       <configuration> 
        <additionalProjectnatures> 
         <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
        </additionalProjectnatures> 
        <additionalBuildcommands> 
         <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
        </additionalBuildcommands> 
        <downloadSources>true</downloadSources> 
        <downloadJavadocs>true</downloadJavadocs> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.5.1</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArgument>-Xlint:all</compilerArgument> 
        <showWarnings>true</showWarnings> 
        <showDeprecation>true</showDeprecation> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2.1</version> 
       <configuration> 
        <mainClass>org.test.int1.Main</mainClass> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

这里是错误:

ArtifactDescriptorException: Failed to read artifact descriptor for javax.inject:javax.inject:jar:1: ArtifactResolutionException: Failure to transfer javax.inject:javax.inject:pom:1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact javax.inject:javax.inject:pom:1 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for javax.servlet:jstl:jar:1.2: ArtifactResolutionException: Failure to transfer javax.servlet:jstl:pom:1.2 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact javax.servlet:jstl:pom:1.2 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for javax.servlet:servlet-api:jar:2.5: ArtifactResolutionException: Failure to transfer javax.servlet:servlet-api:pom:2.5 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact javax.servlet:servlet-api:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for junit:junit:jar:4.7: ArtifactResolutionException: Failure to transfer junit:junit:pom:4.7 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact junit:junit:pom:4.7 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for log4j:log4j:jar:1.2.15: ArtifactResolutionException: Failure to transfer log4j:log4j:pom:1.2.15 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact log4j:log4j:pom:1.2.15 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for mysql:mysql-connector-java:jar:5.1.35: ArtifactResolutionException: Failure to transfer mysql:mysql-connector-java:pom:5.1.35 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact mysql:mysql-connector-java:pom:5.1.35 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.aspectj:aspectjrt:jar:1.6.10: ArtifactResolutionException: Failure to transfer org.aspectj:aspectjrt:pom:1.6.10 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.aspectj:aspectjrt:pom:1.6.10 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:jcl-over-slf4j:jar:1.6.6: ArtifactResolutionException: Failure to transfer org.slf4j:jcl-over-slf4j:pom:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.slf4j:jcl-over-slf4j:pom:1.6.6 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:slf4j-api:jar:1.6.6: ArtifactResolutionException: Failure to transfer org.slf4j:slf4j-api:pom:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.slf4j:slf4j-api:pom:1.6.6 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:slf4j-log4j12:jar:1.6.6: ArtifactResolutionException: Failure to transfer org.slf4j:slf4j-log4j12:pom:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.slf4j:slf4j-log4j12:pom:1.6.6 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework:spring-context:jar:3.1.1.RELEASE: ArtifactResolutionException: Failure to transfer org.springframework:spring-context:pom:3.1.1.RELEASE from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework:spring-context:pom:3.1.1.RELEASE from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework:spring-jdbc:jar:3.1.1.RELEASE: ArtifactResolutionException: Failure to transfer org.springframework:spring-jdbc:pom:3.1.1.RELEASE from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework:spring-jdbc:pom:3.1.1.RELEASE from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework:spring-webmvc:jar:3.1.1.RELEASE: ArtifactResolutionException: Failure to transfer org.springframework:spring-webmvc:pom:3.1.1.RELEASE from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework:spring-webmvc:pom:3.1.1.RELEASE from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org pom.xml /easypark line 1 Maven Dependency Problem 
Missing artifact commons-logging:commons-logging:jar:1.1.1 pom.xml /easypark line 1 Maven Dependency Problem 
Missing artifact org.springframework:spring-beans:jar:3.2.2.RELEASE pom.xml /easypark line 1 Maven Dependency Problem 
Missing artifact org.springframework:spring-core:jar:3.2.2.RELEASE pom.xml /easypark line 1 Maven Dependency Problem 

我怎样才能解决这些错误?

回答

1

我已经试过你的POM,没有任何问题:

[INFO] Wrote Eclipse project for "easypark" to D:\NAR8_3G\git\test. 
[INFO] 
     Javadoc for some artifacts is not available. 
     List of artifacts without a javadoc archive: 
     o org.springframework:spring-context:3.1.1.RELEASE 
     o org.springframework:spring-aop:3.1.1.RELEASE 
     o aopalliance:aopalliance:1.0 
     o org.springframework:spring-asm:3.1.1.RELEASE 
     o org.springframework:spring-expression:3.1.1.RELEASE 
     o org.springframework:spring-webmvc:3.1.1.RELEASE 
     o org.springframework:spring-context-support:3.1.1.RELEASE 
     o org.springframework:spring-web:3.1.1.RELEASE 
     o log4j:log4j:1.2.15 
     o mysql:mysql-connector-java:5.1.35 
     o javax.servlet:servlet-api:2.5 
     o javax.servlet.jsp:jsp-api:2.1 
     o javax.servlet:jstl:1.2 
     o junit:junit:4.7 
     o org.springframework:spring-jdbc:3.1.1.RELEASE 
     o org.springframework:spring-tx:3.1.1.RELEASE 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4:05.386s 
[INFO] Finished at: Sun Jun 21 23:55:53 CST 2015 
[INFO] Final Memory: 8M/223M 
[INFO] ------------------------------------------------------------------------ 

你能否尝试 “mvn -U install”? -U将强制更新您的存储库。

2

我用.jar文件手动安装了所有依赖项。

一个与Maven的要点是,它自动dowloads的依赖关系(通常文件)。换句话说,我怀疑你不知道你在这里做什么,除非你手动下载文件有一个特定的原因。

Maven下载的所有依赖项都存储在您自己的本地存储库中(通常为〜/ .m2)。

我刚刚测试了您的pom文件,并且没有错误,所有依赖项都正确下载。要解决您的错误,您可以简单地删除本地存储库中的文件夹,然后重新构建让Maven下载依赖关系的项目。

+0

嗨,谢谢你的回答。 我其实不知道我在做什么,这是真的。我知道maven会下载所有的依赖关系,但我不知道如何在sts中这样做。 我问小组他们是如何设法使用它的,但我没有从他们那里得到答案。所以,我认为这些问题来自于我不了解maven的事实。我会尽力解决这个问题。谢谢您的帮助。 – Bertos