org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException:用户名或密码错误 [28000-200]

Amy*_*yAC 1 h2 spring-boot

这是错误消息。

    2020-06-15 13:10:23.623 ERROR 37317 --- [nio-8887-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]
### The error may exist in tech/bootcamp/community/mapper/UserMapper.java (best guess)
### The error may involve tech.bootcamp.community.mapper.UserMapper.insert
### The error occurred while executing an update
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]] with root cause

org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]
at tech.bootcamp.community.controller.AuthorizeController.callback(AuthorizeController.java:52) ~[classes/:na]

@Autowired
private UserMapper userMapper;
Run Code Online (Sandbox Code Playgroud)

它说这一行导致了错误。

        userMapper.insert(user);
Run Code Online (Sandbox Code Playgroud)

那么用户名和密码到底是什么?

yuk*_*ane 5

您可以设置application.properties:

spring.datasource.username=dbuser
spring.datasource.password=dbpass
Run Code Online (Sandbox Code Playgroud)

如果未明确设置,则使用默认值“sa”和“”。