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" /> 配置没有任何问题。

       


posted on 2016-05-26 22:39  未亦末  阅读(833)  评论(0编辑  收藏  举报