SrpingBoot启动报错:Error starting ApplicationContext

本文介绍了在SpringBoot环境下遇到的启动错误,问题在于编译后的classes缺少yml配置信息,导致无法加载dataSource。解决方案是在pom.xml中添加spring-boot-maven-plugin并配置相关资源,重新编译后解决了问题。此外,还提醒读者检查resources文件夹是否被正确配置为源代码目录。
摘要由CSDN通过智能技术生成

Springboot环境下,启动服务器是报错:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2021-5-26 14:26:34.478 ERROR 29736 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

前言

当时看到这个问题我一直以为是我的application.yml配置的有问题,然后又看pom文件,找了好久好久(头发都调了不少)通过查找各种资料,各种博客,终于找到原因:在这里插入图片描述
原来是这个编译的classes中没有编译出yml等配置信息,然后导致启动的时候加载不到dataSource等信息,导致报错。话不多说解决问题,开干!

第一步在pom文件中添加

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>

第二步在pom文件中添加jar:

在这里插入图片描述

第三部重新编译:

在这里插入图片描述
这样基本就可以解决百分之八九十的这样问题

后记

还有可能你的resources文件夹没有设置为系统配置文件夹:

不是如图所示的,那么你也要修改文件夹。在这里插入图片描述
如图一般这个地方会有。
或者:Flie–>Project Structure中如图
在这里插入图片描述
好了小编的博客就到这里了,希望可以帮助各位减少掉头发,谢谢各位看官搜索查看!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值