Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user '16348'@'localhost' (using password: YES))
原配置文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/epet?useUnicode=true&characterEncoding=utf8
username=root
password=root
解决方法:在属性前加jdbc.
将配置文件该为:
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/epet?useUnicode=true&characterEncoding=utf8 jdbc.username=epetadmin jdbc.password=root
spring配置文件改为
<!-- 指定引入文件地址 --> <context:property-placeholder location="jdbc.properties"/> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}"></property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"/> </bean>