Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第1张图片

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第2张图片

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第3张图片

问题就出现在这句话 :

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

  解决办法:配置文件改成比如为user就好了

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第4张图片

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第5张图片

 

我们可以看下这个环境变量在spring 容器启动的时候,这个值到底是什么:

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Canno_第6张图片

你可能感兴趣的:(java)