使用手动下载的依赖项的POM错误

时间:2015-06-21 15:20:21

标签: java maven pom.xml

我正在开发一个小组刚开始使用的网络应用程序,但我无法让它运行。

我是 STS(Spring Tool Suite) 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

如何解决这些错误?

2 个答案:

答案 0 :(得分:2)

  

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

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

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

我刚刚测试了你的 pom 文件,它没有错误,所有依赖项都已正确下载。要解决您的错误,您只需删除本地存储库中的文件夹,然后重新构建项目,让Maven下载依赖项。

答案 1 :(得分: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] ------------------------------------------------------------------------

你可以试试&#34; mvn -U install&#34;? -U将强制更新您的存储库。

相关问题