道非道 非常道

          勤思、謹(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 星期五 閱讀(671) 評論(0)  編輯  收藏 所屬分類: J2EEspring-boot

          主站蜘蛛池模板: 寿宁县| 兴国县| 宝坻区| 兴义市| 安岳县| 三原县| 门源| 大洼县| 文成县| 灵川县| 灵石县| 建始县| 长垣县| 即墨市| 和政县| 阳西县| 玉林市| 双牌县| 南靖县| 偃师市| 通榆县| 客服| 安图县| 石渠县| 昌邑市| 太保市| 镇巴县| 胶州市| 靖远县| 林周县| 任丘市| 桑日县| 阳高县| 富锦市| 南充市| 昭通市| 芷江| 故城县| 涞源县| 乌拉特前旗| 勐海县|