“Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.”
琛ㄧず娌℃湁鎸囧畾鐨勬暟鎹簱url錛屾棤娉曢厤緗暟鎹簱
鎴戜滑鍙互鍦⊿pring Boot欏圭洰鍏ュ彛娉ㄨВ澶勬坊鍔?exclude= {DataSourceAutoConfiguration.class}錛岃〃紺哄彇娑堟暟鎹簮鐨勮嚜鍔ㄩ厤緗?/p>
濡傦細(xì)
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; /** * 琛ㄧず鍙栨秷鏁版嵁婧愮殑鑷姩閰嶇疆 */ @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) public class SpringbootWeb01Application { public static void main(String[] args) { SpringApplication.run(SpringbootWeb01Application.class, args); } }
鎴戜滑闇瑕乤pplication.yml鏂囦歡涓嬫坊鍔犲涓嬮厤緗?/p>
server: port: 8080 spring: datasource: url: jdbc:mysql://localhost:3306/springboottest driver-class-name: com.mysql.cj.jdbc.Driver password: 88888888 username: jiade