1、未配置jdbc依赖项会报错找不到配置类(未配置yml、properties)
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'dataSource':
Unsatisfied dependency expressed through field 'basicProperties';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties':
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
2、已配置依赖项的通常情况会报url错误
Fail to configure a DataSource :'url' attribute is not specified ...
3、此时需要在yml 、properties中配置先排除jdbc配置Bean
spring.autoconfigure.exclude:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
感兴趣的可以了解下类内部的配置详情
4、在启动类注解上排除Druid自动配置类
@SpringBootApplication(exclude={DruidDataSourceAutoConfigure.class})
5、maven进行clean后重新编译项目启动成功,接口正常访问(除数据库操作的接口)
PS:1、注意排除Bean不要出现引包错误;
2、Spring版本2.0.3.RELEASE,不同版本排除类可能有差异,具体需要查看报错详情,思路事一样的。