【Spring boot 常见问题】

本文主要讨论了Spring Boot项目中遇到的一些常见问题及解决方法,包括:spring-boot-starter-parent报红的处理,SpringBoot中spring-boot-maven-plugin报错的解决,以及SpringBoot启动时报错Error starting ApplicationContext的解决策略,如考虑使用嵌入式数据库,import changes并重新编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


总结几个常见的问题的解决方案,当时遇到也是多次百度,实践才发现应该这么去解决~
做个笔记~

关于spring-boot-starter-parent报红的解决方法

File -> Invalidate Caches / Restart... -> Invalidate and Restart就能解决了。

这个操作其实是把IDEA清除缓存重启了,这只是其中一种方法,也是最简单的。

StackOverFlow解决方案
优快云其他博主解决方案
Java技能树深入研究容器List的功能方法

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

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值