springboot2.0.0配置多數據源出現jdbcUrl is required with driverClassName的錯誤
更新時間:2020年11月06日 10:35:54 作者:二十同學
這篇文章主要介紹了springboot2.0.0配置多數據源出現jdbcUrl is required with driverClassName的錯誤,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
在Spring Boot 2.0配置多數據源和Spring Boot 1.5.x之前,一些配置及用法多少有些不同,其中一個問題就是“jdbcUrl is required with driverClassName.”的錯誤
解決辦法:
在配置文件中使用spring.datasource.jdbc-url,而不是通常使用的spring.datasource.url
spring: datasource: master: jdbc-url: jdbc:postgresql://192.168.1.2:5432/test?useUnicode=true&characterEncoding=utf8 username: postgres password: postgres driverClassName: org.postgresql.Driver maxActive: 10 maxIdle: 3 worker: jdbc-url: jdbc:postgresql://192.168.1.3:5432/test?useUnicode=true&characterEncoding=utf8 username: postgres password: postgres driverClassName: org.postgresql.Driver maxActive: 10 maxIdle: 3
第二種方法:
在數據源配置時使用DataSourceProperties方法。
到此這篇關于springboot2.0.0配置多數據源出現jdbcUrl is required with driverClassName的錯誤的文章就介紹到這了,更多相關springboot多數據源錯誤內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- spring boot使用sharding jdbc的配置方式
- 詳解springboot采用多數據源對JdbcTemplate配置的方法
- SpringBoot多數據源配置詳細教程(JdbcTemplate、mybatis)
- 詳解Springboot之整合JDBCTemplate配置多數據源
- springboot+springJdbc+postgresql 實現多數據源的配置
- springboot實現以代碼的方式配置sharding-jdbc水平分表
- SpringBoot3+ShardingJDBC5.5.0 讀寫分離配置的實現
- SpringBoot?配置多個JdbcTemplate的實現步驟
- SpringBoot+MybatisPlus+jdbc連接池配置多數據源的實現
- Spring?JDBC配置與使用的實現