项目spring boot无法识别依赖项

时间:2018-04-17 17:07:34

标签: java spring maven spring-boot

我已使用spring boot initializer初始化了一个spring boot starter项目。我的pom.xml看起来像这样:

<groupId>com.stuff</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>my-project</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.12.RELEASE</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.7</java.version>
</properties>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</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>

当我运行Maven测试时,我得到:

java.lang.NoClassDefFoundError: Could not initialize class org.springframework.test.context.junit4.SpringRunner

但在家属中,有问题的课程! (将Junit 4.12添加为pom中的依赖并不会改变任何内容)

当我将应用程序作为spring boot应用程序运行时,我得到了另一个NoClassFounder错误! java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 即使这种依赖性也存在于Maven家属中吗?

我正在使用Eclipse Kepler,Java 7,Maven 3.2

0 个答案:

没有答案
相关问题