1. 程式人生 > >spring boot 啟動報錯:Cannot determine embedded database driver class for database type NONE

spring boot 啟動報錯:Cannot determine embedded database driver class for database type NONE

info for bubuko 報錯 spring free 增加 .com control

錯誤原因:spring boot默認會加載org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration類,DataSourceAutoConfiguration類使用了@Configuration註解向spring註入了dataSource bean。因為工程中沒有關於dataSource相關的配置信息,當spring創建dataSource bean因缺少相關的信息就會報錯。

解決辦法:第一種:在Application類上增加@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}),阻止spring boot自動註入dataSource bean

     第二種:增加數據庫配置相關信息

技術分享圖片

springboot之freemarker:

創建springboot項目,在pom中添加了freemarker的jar包,

技術分享圖片

在controller層寫好相關代碼並且把信息傳到指定的.ftl文件中,

技術分享圖片

在.ftl中把信息取出來

技術分享圖片

啟動,運行正常!

技術分享圖片

spring boot 啟動報錯:Cannot determine embedded database driver class for database type NONE