java - 无法解析intellij想法中的弹簧注释
问题描述
我下载了jdk 11、maven 3.6.3和Itellj Idea并导入了一个项目:
mvn clean install
但我总是得到这个错误:
Cannot resolve symbol 'SpringBootApplication'
pom.xml:
<?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>
<parent>
<groupId>com.xxx.xxx.sofa</groupId>
<artifactId>sofa-spring-boot-pom-parent</artifactId>
<version>1.0.10</version>
</parent>
<properties>
<java.version>11</java.version>
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
<postgres.version>42.2.14</postgres.version>
<h2.version>1.4.200</h2.version>
<swagger.version>2.9.2</swagger.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- DATABASE -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<!-- OPTIONAL TOOLS -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我试图删除.idea
文件夹或“无效的缓存并重新启动”,但第一种方法也没有解决问题。有一个类似的问题Cannot resolve symbol SpringApplication但答案没有解决我的问题。我该如何解决?
解决方案
你好像用的是 Spring Boot 1.0.1 版本,@SpringBootApplication 注解是在 1.2 中引入的
推荐阅读
- angular - 角度注入错误。NulInjectorError: StaticInjectorError(AppModule) [CartPage -> TabsPage]
- python-3.x - 如何使用python而不是aws lambda遍历S3存储桶中的特定文件夹?
- python - python格式文件内容发送小瓶html邮件
- algorithm - 大步使用 std::find 并且只检查结构中的特定成员
- highcharts - 是否可以绘制如下图所示的瀑布图?
- tensorflow - TFLite / mobilenet_v3:您是否在使用带有新模型的旧 TFlite 二进制文件?
- tensorflow - TensorFlow 抑制警告消息
- assembly - 组装 x86 imul 和 div 没有做我期望的事情
- ios - 使用 Swift 调整 UILabel 动态内容以适应特定框架中的文本在宽度和高度上
- json - 处理来自 json 的数据让我无法散列类型“切片”错误 - python