Maven安装在Spring工具套件中给出了多个错误

时间:2017-04-16 03:33:39

标签: spring maven spring-mvc

我正在尝试从https://spring.io/guides/gs/rest-service/

导入STS中的简单代码示例

我已经在我的系统中配置了maven。但是,每当我尝试从命令行或STS运行mvn install时,它都会抛出以下错误 -

堆栈追踪:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-consuming-rest 0.1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.slf4j:slf4j-api:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:jcl-over-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:jul-to-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:log4j-over-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gs-consuming-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\main\resources
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ gs-consuming-rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\classes
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot\1.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar; invalid CEN header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-core\4.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-web\4.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-context\4.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.7\jackson-databind-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.7\jackson-core-2.8.7.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ gs-consuming-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ gs-consuming-rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\test-classes
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot\1.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar; invalid CEN header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-core\4.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-web\4.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-context\4.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.7\jackson-databind-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.7\jackson-core-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\assertj\assertj-core\2.6.0\assertj-core-2.6.0.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-test\4.3.7.RELEASE\spring-test-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ gs-consuming-rest ---
[INFO] Surefire report directory: H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running hello.ApplicationTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 sec <<< FAILURE! - in hello.ApplicationTest
initializationError(hello.ApplicationTest)  Time elapsed: 0.002 sec  <<< ERROR!
java.lang.TypeNotPresentException: Type org.springframework.test.context.junit4.SpringRunner not present
    at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
    at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
    at com.sun.proxy.$Proxy2.value(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.junit4.SpringRunner
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
    at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:349)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
    at java.lang.Class.createAnnotationData(Class.java:3521)
    at java.lang.Class.annotationData(Class.java:3510)
    at java.lang.Class.getAnnotation(Class.java:3415)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:65)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:97)
    at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:222)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


Results :

Tests in error: 
  ApplicationTest.initializationError » TypeNotPresent Type org.springframework....

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.592 s
[INFO] Finished at: 2017-04-15T20:20:09-07:00
[INFO] Final Memory: 24M/183M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project gs-consuming-rest: There are test failures.
[ERROR] 
[ERROR] Please refer to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\surefire-reports for the individual test results.
[ERROR] -> [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/MojoFailureException

下面是我的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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-consuming-rest</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我的配置似乎有些问题,但我无法找到它。 欢迎任何帮助。

1 个答案:

答案 0 :(得分:2)

一些事情

  1. spring-boot-1.5.2.RELEASE.jar,spring-core-4.3.7.RELEASE.jar似乎已损坏,请你试试删除它&amp;让它再次下载。

  2. 它似乎与配置文件“pom.xml”一起运行。

    无法激活请求的配置文件“pom.xml”,因为它不存在。

  3. 确保它应该在没有任何配置文件的情况下运行,您可以在图中看到您可以更改它。 enter image description here