org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection

检查所有数据库代码之后,仍然出现没法连接得情况,经查资料得知:

无法连接数据库的原因在于

<property name="username" value="${username}" /> 这一行因为此时${username}的值并不是jdbc.properties文件中的username值,而是JVM系统环境变量的username。spring容器在管理PropertySource时,不光读取自己写的properties文件,spring也会把JVM system properties和JVM system env properties都读取到容器中,所以请不要使用和JVM properties相同的key。

建议改成如下key值:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection

相关文章:

  • 2021-12-30
  • 2021-06-25
  • 2021-06-19
  • 2021-04-07
  • 2021-09-02
  • 2021-12-13
  • 2022-12-23
  • 2021-08-28
猜你喜欢
  • 2021-09-09
  • 2021-12-20
  • 2021-05-29
  • 2021-10-19
相关资源
相似解决方案