我在application.properties
中提供了用于连接Mysql的凭据,但是spring-boot
无法获得这些凭据。
这是我的application.properties文件:
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost/person_example
spring.datasource.data-username=root
spring.datasource.data-password=password
控制台中显示的错误:
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.15.jar:8.0.15]
答案 0 :(得分:0)
在此处查看有关常见speinh属性的文档:
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
您需要使用spring.datasource.username和spring.datasource.password