'dynamicDataSource' threw exception; nested exception is java.lang.IllegalStateException: dbType not support : null, url null
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
系统启动报错,原因:未读取到多数据源配置:spring.datasource.druid
解决方法:检查配置是否正确、检查启动时加载配置是否有问题
我的case:
bootstrap.xml配置如下:
logging:
config: classpath:log/log4j2-${spring.profiles.active}.xml
server:
port: 1234
spring:
application:
name: xxx-server
#环境 dev|test|prod
profiles:
active: local
错误原因: 导致logging.config中引用的变量在后面,无法找到,配置失效
解决方法:将logging.config挪至文件最后