【发布时间】:2017-04-10 20:29:29
【问题描述】:
我在使用 maven 时遇到如下配置错误
cannot resolve symbol @SpringBootApplication
我也试过了
@Configuration @EnableAutoConfiguration @ComponentScan
但我有一个关于 @EnableAutoConfiguration 的错误
然后我尝试使缓存无效,但只是在那段时间工作。我运行我的应用程序,但出现以下问题。
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.support.AopUtils
我无法解决这个问题,所以我尝试使用 gradle 并且没有任何问题,比如魅力。但我不知道为什么它适用于 gradle 而不适用于 maven?
我对 gradle 了解不多。和maven一样吗?意味着我们可以像 maven 一样使用吗?
请建议我解决 intellij IDEA 中的所有问题。任何链接或建议将不胜感激。
提前致谢
我的 pom 看起来像下面
<?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>com.example</groupId>
<artifactId>testfolio</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestFolio</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.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.8</java.version>
</properties>
<dependencies>
<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>
</project>
【问题讨论】:
-
尝试使用
mvn dependency:purge-local-repository清理 maven 存储库,然后尝试刷新依赖项。看起来您的存储库以某种方式损坏了。 -
pom.xml对我来说看起来不错,所以我认为您的问题可能出在您的 maven 安装上。如果您导航到终端中的项目目录并输入mvn compile,这会起作用吗? -
@WillHumphreys mvn compile build success 。但是那个错误仍然存在。 mvn --version apache maven 3.3.9版
-
命令行上的 Maven 很好用。有助于缩小范围。也许 IntelliJ 没有使用相同的版本,或者它的配置不同。你能在 IntelliJ 中检查你的 Maven 设置,看看它们是否与你的命令行设置匹配。检查版本是否相同,并且它们将依赖项存储在相同的位置。
标签: java maven spring-mvc intellij-idea spring-boot