SSM整合搭建过程中的一个怪异问题

    好久没有搭建框架了,昨天开始试图搭建一个SSM框架,各种配置文件搭建成功,服务器也启动正确,但是在运行过程中,发现总是不能获取JDBC,不能够创建连接池工厂,报错如下:网页报500错误码

SEVERE: Servlet.service() for servlet [springmvc] in context with path [/OrdersForGoods] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'litan'@'localhost' (using password: YES))
### The error may exist in com/yusys/dao/GoodsMapper.xml
### The error may involve com.yusys.dao.GoodsMapper.findAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'litan'@'localhost' (using password: YES))] with root cause
java.sql.SQLException: Access denied for user 'litan'@'localhost' (using password: YES)

搜索网上,说是没有导入包,包导入错误,或者数据源属性文件后面多空格,等等,总之是数据源属性与数据源配置中取值不一致

同时我发现一个很奇怪的问题,当我将进行如下配置时候就会出现上面的报错:

属性文件:

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssm
username=root
password=123456

数据源配置

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="singleton">
      <property name="driverClassName" value="${driver}"/>
      <property name="url" value="${url}"/>
      <property name="username" value="${username}"/>
      <property name="password" value="${password}"/>
     </bean>

但是我如果将上述配置更改为如下,也就是将username改变一下就正常了,很是奇怪。

属性文件中的配置为:

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssm
uname=root

password=123456

数据源配置

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="singleton">
      <property name="driverClassName" value="${driver}"/>
      <property name="url" value="${url}"/>
      <property name="username" value="${uname}"/>
      <property name="password" value="${password}"/>
     </bean>


猜你喜欢

转载自blog.csdn.net/zuixiaoyao_001/article/details/78991603
今日推荐