亚洲色蝴蝶中文娱乐网,在线亚洲欧美一区二区中文字幕,无人视频在线观看视频高清视频,99午夜国产精品一区二区,人人妻人人爽人人狠狠

初步搭建springboot應(yīng)用,報(bào)錯(cuò):Failed to configure a DataSour

時(shí)間:2020-06-29 10:31:01 類型:JAVA
字號(hào):    

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

  翻譯就是:無法配置DataSource:未指定'url'屬性,也無法配置嵌入數(shù)據(jù)源。

  總之意思就是你在應(yīng)用中沒有配置datasource的一些相關(guān)屬性,例如:地址值啊,數(shù)據(jù)庫驅(qū)動(dòng)啊,用戶名啊,密碼之類的

  SpringBoot的最大一個(gè)好處就是自動(dòng)配置:所以我們只是需要給他配置文件的值,它就會(huì)自動(dòng)配置。配置在application.properties文件中

  那么我將把SpringBoot的一些最基本的配置信息給大家站出來:

#訪問根路徑

#應(yīng)用名稱
spring.application.name=springboot-demo

#訪問端口號(hào)
server.port=80

#編碼格式
server.tomcat.uri-encoding=utf-8

#數(shù)據(jù)庫相關(guān)配置
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # MySQL8.0
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/stu_info
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

#session生命周期
server.servlet.session.timeout=30m

  當(dāng)然,也可以不配置,但是你需要聲明一下

  啟動(dòng)類頭部聲明就可以了:


  @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})


<