Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
今天搞了个读写分离多数据源的项目,启动时报了这个错,查了好几个博客都说用在启动类加
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
但是我加了还是报这个错
后面我查了下@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)不生效需要加入
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, DruidDataSourceAutoConfigure.class , HibernateJpaAutoConfiguration.class})
因为druid-spring-boot-starter 会再次扫描数据源