亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

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

瀏覽:6日期:2023-06-28 08:15:35
Spring boot 數(shù)據(jù)源未配置異常問(wèn)題

在使Springboot自動(dòng)生成的項(xiàng)目框架時(shí)如果選擇了數(shù)據(jù)源,比如選擇了mysql,生成項(xiàng)目之后,啟動(dòng)會(huì)報(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).

問(wèn)題分析

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

解決方案

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

(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.HikariDataSourcespring.datasource.driverClassName=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/testspring.datasource.username=rootspring.datasource.password=rootspringboot啟動(dòng)提示缺少數(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 他就會(huì)默認(rèn)需要加載數(shù)據(jù)庫(kù)相關(guān)的配置

可以加上

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 国产精彩对白综合视频 | 欧美视频在线观看一区二区 | 国产精品系列在线观看 | 国产成人激烈叫床声视频对白 | 性大片免费观看yy | 精品一区二区在线欧美日韩 | 公么吃奶满足了我苏媚 | 日本一级大毛片a一 | 国产大秀视频一区二区三区 | 国产精品国产亚洲精品不卡 | 公又粗又长又大又深好爽日本 | 久久最新免费视频 | 手机看片日韩国产 | 免费国产成人综合 | 欧美一区二三区 | 中文字幕一区二区视频 | 国产又色又粗又黄又爽免费 | 国产精品久久久久一区二区 | 久久久久久91香蕉国产 | 国产在线精品一区二区夜色 | 美女18一级毛片免费看 | 谁有免费黄色网址 | 成人伦理影院 | 亚洲毛片免费在线观看 | 午夜拍拍| 亚洲黄色在线看 | 成人国产欧美精品一区二区 | 成人黄色在线视频 | 久久www免费人成_看片美女图 | 九九天天影视 | 久久视热这只是精品222 | 欧美洲精品亚洲精品中文字幕 | 国产小视频免费看 | 免费一级毛片在线播放视频 | 国产秦先生大战白丝97在线 | 色婷婷久久免费网站 | 久久国产自偷自免费一区100 | 午夜影院在线播放 | 欧美一区二区三区日韩免费播 | 国产一区免费观看 | 国产高清狼人香蕉在线观看 |