Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your c

在SpringBoot项目中,遇到因未正确配置DataSource而引发的HibernateJpaAutoConfiguration错误。解决办法是移除@SpringBootApplication注解中的exclude参数,具体地,删除(exclude=DataSourceAutoConfiguration.class)这一段代码。

Spring Boot开发中 遇到的问题描述:

Description:

Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
    - Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
    - Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans of type org.springframework.boot.jta.XADataSourceWrapper


Action:

Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.


Process finished with exit code 1

 

解决办法:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

public class PagingSortingApplication {

 

更换为:

@SpringBootApplication

public class PagingSortingApplication {

也就是去掉:(exclude = DataSourceAutoConfiguration.class) 这段代码即可!  

备注: 每个人遇到对的问题不一样,我的遇到了这个问题,去掉这哥注解,问题就得到了,解决,希望能帮到正在看我博客的你!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值