每当我对程序发出 Get 请求时,都会收到错误
org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-199]
我没有 Spring 安全性。我的 application.properties 看起来像这样
spring.datasource.url=jdbc:h2:file:C:/Projects/database/demo
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.path=/h2console
如您所见,我没有设置密码,这很奇怪,因为当我登录控制台时,我必须使用用户名:sa 和密码:password 登录。
这是我在 postman 中遇到的错误:
{
"timestamp": "2019-10-15T14:32:53.100+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection",
"path": "/api/getallcarmakes"
}
发生了什么事?谢谢。
最佳答案
由于您的用户/密码不正确,因此无法连接。
如果登录控制台时的密码是password
,您还应该在application.properties中进行设置。
因此设置 spring.datasource.password=password
应该有效。
关于java - 在 Spring Boot 中发出 Get 请求时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58397197/