道非道 非常道

          勤思、謹(jǐn)言、慎行、厚積、薄發(fā)

          統(tǒng)計(jì)

          web

          天圓

          經(jīng)濟(jì) 政治 軍事

          鍵康

          解決If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.問題


          springboot項(xiàng)目搭建遇到問題,提供兩種解決方法:

          “Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.”

          表示沒有指定的數(shù)據(jù)庫url,無法配置數(shù)據(jù)庫

          image.png

          方法一:不使用數(shù)據(jù)源配置

          我們可以在Spring Boot項(xiàng)目入口注解處添加 exclude= {DataSourceAutoConfiguration.class},表示取消數(shù)據(jù)源的自動(dòng)配置

          如:

          import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;   /**  * 表示取消數(shù)據(jù)源的自動(dòng)配置  */ @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) public class SpringbootWeb01Application {       public static void main(String[] args) {         SpringApplication.run(SpringbootWeb01Application.class, args);     }   }  

          方法二:按照報(bào)錯(cuò),我們添加數(shù)據(jù)庫配置

          我們需要application.yml文件下添加如下配置

          server:   port: 8080 spring:   datasource:     url: jdbc:mysql://localhost:3306/springboottest     driver-class-name: com.mysql.cj.jdbc.Driver     password: 88888888     username: jiade 


          作者:程序員溪言
          鏈接:https://www.jianshu.com/p/54db85befb01
          來源:簡書
          著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請注明出處。

          posted on 2021-12-15 19:59 星期五 閱讀(673) 評論(0)  編輯  收藏 所屬分類: J2EEspring-boot

          主站蜘蛛池模板: 青龙| 莱西市| 公主岭市| 中牟县| 乐业县| 聂拉木县| 浦江县| 湾仔区| 沂南县| 宜川县| 江山市| 西乌珠穆沁旗| 阿克陶县| 大理市| 海阳市| 内黄县| 昆明市| 咸阳市| 卢湾区| 南充市| 甘德县| 酉阳| 海宁市| 越西县| 公主岭市| 定西市| 武冈市| 辽宁省| 永和县| 郴州市| 浮山县| 增城市| 舒兰市| 镇原县| 榆社县| 朔州市| 长汀县| 达日县| 泾川县| 绥芬河市| 炎陵县|