道非道 非常道

          勤思、謹(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ù)庫(kù)url,無法配置數(shù)據(jù)庫(kù)

          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);     }   }  

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

          我們需要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
          來源:簡(jiǎn)書
          著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。

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

          主站蜘蛛池模板: 兴仁县| 吉木萨尔县| 文昌市| 广元市| 南平市| 梁河县| 盱眙县| 桂林市| 基隆市| 饶阳县| 南平市| 信丰县| 新泰市| 密山市| 灵宝市| 钦州市| 抚州市| 盐山县| 陈巴尔虎旗| 许昌市| 福建省| 达尔| 贡嘎县| 萝北县| 萨迦县| 集安市| 澎湖县| 南漳县| 同德县| 胶州市| 青神县| 香河县| 富阳市| 泊头市| 天门市| 若尔盖县| 彰化县| 平陆县| 南京市| 绍兴县| 拜泉县|