【问题标题】:Maven build fails with error message Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolvedMaven 构建失败并显示错误消息 Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 或其依赖项之一无法解析
【发布时间】:2014-12-22 08:38:54
【问题描述】:

我正在尝试使用 maven 构建一个 java spring 项目(heroku 入门指南的默认项目)。出于某种原因,我不断收到以下错误。机器访问互联网应该没有任何问题。

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test 
(default-test) on project spring-hibernate-template: 
Execution default-test of goal org.apache.maven.plugins:maven-surefire-    
plugin:2.12.4:test failed: 
Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its 
dependencies could not be resolved: 
Cannot access central (http://repo.maven.apache.org/maven2) in offline mode and
the artifact org.codehaus.plexus:plexus-utils:jar:1.1 has not been downloaded 
from it before. 

我的 pom 文件以防万一。

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>spring-hibernate-template</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <org.springframework.version>3.1.1.RELEASE</org.springframework.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <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>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.2.8</version>
    </dependency>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.10.Final</version>
    </dependency>
    <dependency>
        <groupId>com.github.jsimone</groupId>
        <artifactId>webapp-runner</artifactId>
        <version>7.0.34.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.github.jsimone</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>7.0.34.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

【问题讨论】:

  • 还要注意,您使用的库版本,例如 Spring,已经完全过时了; Spring 现在是 4.1 版本,Hibernate 是 4.2。

标签: java eclipse spring maven heroku


【解决方案1】:

错误信息显示它是in offline mode

如果您没有在命令行上使用-o--offline 进行构建,那么您的settings.xml 文件中可能存在&lt;offline/&gt; 元素。

或者,如果您以这种方式构建,也可以通过您的 IDE 应用此设置。

【讨论】:

    猜你喜欢
    • 2015-07-24
    • 2018-12-29
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 2014-03-21
    • 2012-09-14
    相关资源
    最近更新 更多