我使用Spring Initializr生成了一个Spring Boot Web应用程序,使用嵌入式Tomcat + Thymeleaf模板引擎,并将package作为可执行JAR文件.
使用的技术:
Spring Boot 1.4.2.RELEASE,Spring 4.3.4.RELEASE,Thymeleaf 2.1.5.RELEASE,Tomcat Embed 8.5.6,Maven 3,Java 8.
现在我想用类实现一个Test SpringApplicationConfiguration,所以我导入了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但即使我已多次更新项目,我也会收到此错误
The import org.springframework.boot.test.SpringApplicationConfiguration cannot be resolved
Run Code Online (Sandbox Code Playgroud)
我还尝试通过右键单击Eclipse中的pom.xml和'Maven Add Dependency'来添加依赖项,
做mvn clean dependency:tree 依赖是存在的,但是做了mvn clean compile,mvn dependency:purge-local-repository 我得到了package org.springframework.test.annotation does not exist
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.2.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] | | | …Run Code Online (Sandbox Code Playgroud)