情况如下:
按下ALT+Enter键不能自动导入包
解决办法:
在pom.xml文件中的标签中间加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
回到报错的类,手动输入
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
让包能够顺利导入
最后,问题完美解决!
其他注释出现这个问题时也可以尝试利用类似办法