Spring boot 編譯報錯 Failed to auto-configure a DataSource

第一次用spring boot ,踩了一天的坑,記錄一個

Description:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

Reason: Failed to determine a suitable 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).

我的報錯修改了兩個地方,第一是在啓動類的@EnableAutoConfiguration或@SpringBootApplication中添加exclude= {DataSourceAutoConfiguration.class}

第二要在pom.xml裏的plugins添加

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章