最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring boot 數(shù)據(jù)源未配置異常的解決

 更新時(shí)間:2021年08月02日 09:32:43   作者:程序新視界  
這篇文章主要介紹了Spring boot 數(shù)據(jù)源未配置異常的解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

Spring boot 數(shù)據(jù)源未配置異常

問題

在使Springboot自動生成的項(xiàng)目框架時(shí)如果選擇了數(shù)據(jù)源,比如選擇了mysql,生成項(xiàng)目之后,啟動會報(bào)一下異常:

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).

問題分析

導(dǎo)致此問題的原因?yàn)椋瑂pringboot生成的項(xiàng)目啟動時(shí)會自動注入數(shù)據(jù)源。而此時(shí)在配置文件中并沒有配置數(shù)據(jù)源信息,因此會拋出異常。

解決方案

(1)如果暫時(shí)不需要數(shù)據(jù)源,可將pom文件中的mysql和mybatis(或其他數(shù)據(jù)源框架)注釋掉,即可正常啟動。

(2)在@SpringBootApplication中排除其注入

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

(3)提供數(shù)據(jù)源的配置或其他數(shù)據(jù)源配置,此處提供默認(rèn)配置示例,在application.properties文件中添加以下配置項(xiàng):

# 主數(shù)據(jù)源,默認(rèn)的
#spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root

springboot啟動提示缺少數(shù)據(jù)源

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

正解:

因?yàn)閟pring boot只要你在pom中引入了mybatis-spring-boot-starter 他就會默認(rèn)需要加載數(shù)據(jù)庫相關(guān)的配置

可以加上

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

建宁县| 朝阳市| 泰来县| 马龙县| 高密市| 西昌市| 渭南市| 闽清县| 政和县| 轮台县| 峨山| 泰州市| 桦川县| 霍林郭勒市| 环江| 昌吉市| 武威市| 宾川县| 聂拉木县| 静海县| 留坝县| 商南县| 通山县| 泰安市| 安新县| 蓝田县| 全椒县| 邢台县| 喜德县| 长沙县| 淮北市| 永济市| 麻栗坡县| 来安县| 兴仁县| 宁乡县| 阜康市| 寿宁县| 岗巴县| 南城县| 饶阳县|