第一次運行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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章