支持读取druid特殊配置url

This commit is contained in:
mazhicheng 2020-07-06 19:57:56 +08:00
parent a9f7a54bf8
commit 850329960b
1 changed files with 3 additions and 0 deletions

View File

@ -253,6 +253,9 @@ public class ContextHelper implements ApplicationContextAware {
public static String getJdbcUrl() { public static String getJdbcUrl() {
Environment environment = getApplicationContext().getEnvironment(); Environment environment = getApplicationContext().getEnvironment();
String jdbcUrl = environment.getProperty("spring.datasource.url"); String jdbcUrl = environment.getProperty("spring.datasource.url");
if(jdbcUrl == null){
jdbcUrl = environment.getProperty("spring.datasource.druid.url");
}
if(jdbcUrl == null){ if(jdbcUrl == null){
String master = environment.getProperty("spring.datasource.dynamic.primary"); String master = environment.getProperty("spring.datasource.dynamic.primary");
jdbcUrl = environment.getProperty("spring.datasource.dynamic.datasource."+master+".url"); jdbcUrl = environment.getProperty("spring.datasource.dynamic.datasource."+master+".url");