zoukankan      html  css  js  c++  java
  • idea开发springboot 的mysql数据库连接问题

    今天在家用idea进行springboot开发,前面一些坑相对避免了,但是到数据库这块总是连接不上,报错主要是:

    Access denied for user 'root'@'localhost' (using password: NO)

    网页上显示错误

    This application has no explicit mapping for /error, so you are seeing this as a fallback.

    Sun May 06 15:18:14 CST 2018
    There was an unexpected error (type=Internal Server Error, status=500).
    nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) ### The error may exist in file [D: est argetclassesmapperUser.xml] ### The error may involve com.example.mapper.UserMapper.getUserById ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

    我检查我的密码等都是正确的,网上各种查,最后,原来是被idea坑了,

    根据idea的提示写出来的数据源信息是:

    
    
    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test
    spring.datasource.data-username=root
    spring.datasource.data-password=123456
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver


    这个data-username,data-password,driver-class-name不是jdbc数据源的属性字段,所以不识别,当改为如下设置,数据库就连接上了。

  • 相关阅读:
    继承
    JAVA接口的继承与集合
    JAVA接口
    c++程序—敲桌子
    c++程序—水仙花数
    c++程序—while猜数字游戏
    c++程序—switch分支
    c++程序—三目运算符
    c++程序—if语句实践
    c++程序—选择结构
  • 原文地址:https://www.cnblogs.com/xiaoyao-001/p/9184804.html
Copyright © 2011-2022 走看看