第一次运行spring boot+mybatis报错,连接数据库出错

If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.

具体报错信息

Description:
 
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
//无法配置数据库,没有指定url属性,并且无法配置embedded datasource
Reason: Failed to determine a suitable driver class
//原因:无法明确指定正确的驱动类(driver.class)
 
Action:
 
Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
 
//建议:
//如果如果需要加载嵌入式的数据库,请将他放入路径中
//如果有数据库设置需要从指定配置文件中加载,需要调用该配置文件(目前没有活动的配置文件)
 
Process finished with exit code 1

方法一

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
在启动类中加入
在这里插入图片描述

方法二

相信你能看到这上面的方法一还是没用。

那就用我自创的玄学

复制上面代码,更新maven,运行,然后应该还是报错,你把添加的这些代码去掉,在更新maven,运行就成了,亲自测试,还是两次,都成了!!!
有知道为啥的可以留言,暂定为 玄学,哈哈

有可能是没有加截到配置文件,可以尝试在pom.xml文件的build标签中加入如下内容
<resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章