Spring mybatis Access denied for user 'root'@'localhost' (using password:YES)

     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 id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
<property name="locations">  
<list>  
                 <value>/WEB-INF/classes/dbconfig.properties</value>  
            </list>  
        </property>  

</bean> 


这个就没问题了 。


     另外

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

       


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值