【springboot整合druid】java.sql.SQLException: url not set


問題描述

未使用自動裝配的機制,實現springboot整合druid時(就是使用druid的jar包,而不是druid-spring-boot-starter)報錯

<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>druid</artifactId>
  <version>1.1.22</version>
</dependency>

問題原因

1、@ConfigurationProperties(prefix = "spring.datasource.druid")配置的prefix和.yml(.properties)中的不一致

2、注解@ConfigurationProperties(prefix = "xxxx")位置標注錯誤,應該放在對應的bean上,而不是類上


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM