spring 3.X 提供了  <context:property-placeholderlocation="classpath:prop/jdbc.properties" />

方便加载数据库配置。

今天我用spring4.X 和 dbcp2 集成 用 <context:property-placeholderlocation="classpath:prop/jdbc.properties" />  加载配置文件。

值都能取到 但是连接数据库时总是报  Access denied for user 'root'@'localhost' (using password:YES) 本以为是数据库密码的问题,重新改了数据库密码,还是报同样的错误。 。最后我改 <context:property-placeholderlocation="classpath:prop/jdbc.properties" /> 为

 <bean ><list>  
                 <value>/WEB-INF/classes/dbconfig.properties</value>  
            </list>  
        </property>  

</bean> 


这个就没问题了 。


     另外

         亲测:    spring 3.x +dbcp  用 <context:property-placeholderlocation="classpath:prop/jdbc.properties" /> 配置没有任何问题。

       


相关文章:

  • 2021-07-16
  • 2021-11-16
  • 2021-06-26
  • 2021-07-30
  • 2022-02-25
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-02
  • 2021-04-03
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案