在沒有配置數據庫的時候, 直接啟動springBoot 項目 會有報錯
Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
這是因為springBoot 在啟動的時候, spring boot默認會加載org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration類,DataSourceAutoConfiguration類使用了@Configuration注解向spring注入了dataSource bean。因為工程中沒有關於dataSource相關的配置信息,當spring創建dataSource bean因缺少相關的信息就會報錯。
解決方法(紅色字體, 是添加的東西)
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
其中exclude 表示排除, 不包含一些東西
