问题①:
我们出现的问题就是我们数据库的密码不能以0开头,在springboot配置中会涉及到进制转换!!然鹅我就是以0开头导致一直在报错,所以我们可以通过修改我们的密码进行改错
{
修改密码:
①、使用我们的cmd命令:where mysql找到我们mysql的bin文件位置,使用cmd进入
②、使用命令mysqladmin -uXXXX -p旧密码 password 即可修改我们的mysql密码
③、使用mysql -u用户 -p新密码进入数据库
}
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdbcMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcMappingContext' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcCustomConversions' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.jdbc.core.convert.JdbcCustomConversions]: Factory method 'jdbcCustomConversions' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.relational.core.dialect.Dialect]: Factory method 'jdbcDialect' threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
问题②:
我们如果主机上有多个数据库,我们一定要搞清哪个版本的数据库对应的是哪个端口的。搞清哪个端口的我们一定要将数据库驱动的版本与我们的数据库版本一一对应。(如果我们是5版本的,那么我们就选择5版本中最高的版本)
在yaml配置文件中的配置:
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 1234
url: jdbc:mysql://localhost:3306?useSSL=false
在POM中的配置:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<!--版本一定不要乱了,不配置的话SpringBoot会默认为我们仲裁版本,具体哪个版本看源码,最好自己配置-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
小技巧:我们可以直接在IDEA环境中对我们的数据库进行测试连接。
如果主机中只有一个数据库就不用像我上面那么麻烦
本文档介绍了在SpringBoot中遇到的数据库密码不能以0开头的问题及其解决方案,包括通过CMD命令修改MySQL密码的步骤。同时,提到了在配置文件中指定数据库驱动、用户名、密码和URL的注意事项,以及如何确保数据库驱动版本与数据库版本匹配。在POM文件中展示了具体的依赖配置。此外,还分享了一个小技巧,即在IDEA中直接测试数据库连接。
1936

被折叠的 条评论
为什么被折叠?



