Spring mybatis Access denied for user 'root'@'localhost' (using password:YES) 「爱情、让人受尽委屈。」 2022-08-22 11:27 28阅读 0赞 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" /> 配置没有任何问题。
还没有评论,来说两句吧...