创建spring boot io项目时无法执行目标并测试失败

时间:2018-09-30 06:57:16

标签: spring-boot

好吧,我正在创建一个Spring Boot Stater Maven项目,却遇到了Error。在创建Spring Boot Starter项目时,它显示了测试失败错误。

>     [ERROR] initializationError(com.technostack.rest.webservice.restfulwebservice.RestfulWebserviceApplicationTests)
> Time elapsed: 0.009 s  <<< ERROR!
>     org.springframework.beans.BeanInstantiationException: Failed to instantiate
> [org.springframework.boot.test.context.SpringBootContextLoader]:
> Unresolvable class definition; nested exception is
> java.lang.NoClassDefFoundError:
> org/springframework/context/ApplicationContextException
>     Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
>     Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException
>     
>     [INFO] 
>     [INFO] Results:
>     [INFO] 
>     [ERROR] Errors: 
>     [ERROR]   RestfulWebserviceApplicationTests.initializationError » BeanInstantiation Fail...
>     [INFO] 
>     [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
>     [INFO] 
>     [INFO] ------------------------------------------------------------------------
>     [INFO] BUILD FAILURE
>     [INFO] ------------------------------------------------------------------------
>     [INFO] Total time: 6.164 s
>     [INFO] Finished at: 2018-09-29T23:18:30-07:00
>     [INFO] Final Memory: 35M/277M
>     [INFO] ------------------------------------------------------------------------
>     [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test
> (default-test) on project restful-webservice: There are test failures.
>     [ERROR] 
>     [ERROR] Please refer to R:\restful-webservice\restful-webservice\target\surefire-reports for
> the individual test results.
>     [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and
> [date]-jvmRun[N].dumpstream.
>     [ERROR] -> [Help 1]
>     [ERROR]

下面是我的pom.xml:

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”>     4.0.0

<groupId>com.technostack.rest.webservice</groupId>
<artifactId>restful-webservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>restful-webservice</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.6.BUILD-SNAPSHOT</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </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>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

0 个答案:

没有答案
相关问题