报错如下:
2017-11-19 15:13:40.009 ERROR 15152 --- [nio-8090-exec-2] e.n.y.o.service.LoginModuleService : checkUserInfo: Error message 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 java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
The error may exist in file [D:\Spring\JavaWeb\OnlineBookstore\target\classes\mybatis\mapper\UserInfoMapper.xml]
The error may involve edu.javaee.onlinebookstore.mapper.UserInfoMapper.isNameExist
The error occurred while executing a query
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
application.properties配置如下:
server.port = 8090
spring.mvc.view.prefix = /WEB-INF/jsp/
spring.mvc.view.suffix = .jsp
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/onlinebookstore?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username = root
spring.datasource.password = root
mybatis.typeAliasesPackage = edu.javaee.onlinebookstore.domain
mybatis.config-location = classpath:mybatis/mybatis-config.xml
mybatis.mapper-locations = classpath:mybatis/mapper/*Mapper.xml
logging.file = log/service.log
检查过数据库密码正确,可以通过Navicat访问。