使用spring 连接数据库时,在升级spring boot版本之后,启动项目报错如下:
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
Property: spring.datasource.driverclassname
Value: org.postgresql.Driver
Origin: class path resource [application-postgres.properties]:7:35
Reason: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader
在property文件里面对数据库的定义如下:
spring.datasource.url=jdbc:postgresql://localhost:5432/test
spring.datasource.username=user
spring.datasource.password=ped
spring.datasource.driverClassName=org.postgresql.Driver
数据库DataSource bean的定义如下:
@Configuration
@Profile("postgres")
public class SourceDataSourceConfigurationLocal {
@Bean
@ConfigurationProperties("spring.datasource")
public DataSource sourceDataSource(

在升级Spring Boot版本后,遇到启动时无法绑定'spring.datasource'到javax.sql.DataSource的错误。错误源于properties文件中数据库配置。解决方案是移除特定的配置项,问题得到解决。
最低0.47元/天 解锁文章
1707

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



