Spring boot 常见问题
总结几个常见的问题的解决方案,当时遇到也是多次百度,实践才发现应该这么去解决~
做个笔记~
关于spring-boot-starter-parent报红的解决方法
File -> Invalidate Caches / Restart... -> Invalidate and Restart就能解决了。
这个操作其实是把IDEA清除缓存重启了,这只是其中一种方法,也是最简单的。
SpringBoot中spring-boot-maven-plugin爆红
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 加入与parent中版本相同的version就行-->
<version>2.6.1</version>
</plugin>
</plugins>
</build>
加入与parent中版本相同的version就行 由于我用的是
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
启动SpringBoot报错Error starting ApplicationContext. To display the conditions report re-run
和出现
Action: Consider the following:
If you want an embedded database ……
相关警告~
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 当启动SpringBoot 项目时,先把这个依赖注释掉,启动就不会报错了 -->
<!--<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
最后 import changes ,重新编译一下,在运行就正常了
springboot启动时提示错误:无法加载主类xxx
多种处理方案
1.Rebuild Project,清除缓存;
2.删除项目目录下的target文件;
3.在当前工程路径下,打开Terminal终端,依次执行以下命令:
mvn clean compile
mvn install
mvn spring-boot:run
4
5