【发布时间】:2017-02-17 12:40:33
【问题描述】:
我在 pom.xml 中添加了 spring boot,但它仍然报错。 谁能帮帮我。
报错 The import org.springframework.boot.autoconfigure.SpringBootApplication cannot be resolved
和 SpringBootApplication 无法解析为类型
我的绒球。 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webapp</groupId>
<artifactId>proj1</artifactId>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<version>0.0.1-SNAPSHOT</version>
<name>proj1 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>proj1</finalName>
</build>
</project>
【问题讨论】:
-
您缺少“spring-boot-autoconfigure”jar,不知道为什么。您可以检查它是否在 .m2 目录中。如果是,我会删除它并重新导入项目。
-
我试过了,没用。我在 eclipse 中尝试了相同的代码,没有错误,但是 STS 给出了错误。
-
@Archit,将我的答案 (stackoverflow.com/questions/39245732/…) 链接到这个问题。
-
从命令行运行“mvn clean package”会编译吗?
标签: maven spring-boot pom.xml