springboot报错“Consider revisiting the conditions above or defining a bean of type 'javax.sql.。。。。”的解决

最近刚开始学习srpringboot,在集成mysql和jpa的时候启动springboot遇到了下面的问题:


Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.

2018-05-31 08:37:45.470 ERROR 9052 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************
APPLICATION FAILED TO START
***************************


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




Action:


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


看了网上的添加@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})解决方法都没有用,最后看自己的pom文件发现是在做整合jdbc的时候添加了

                <dependency>

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<scope>test</scope>

</dependency>


整合jpa的时候又添加了

                <dependency>

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>

</dependency>

                <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>

</dependency>


感觉是“mysql-connector-java”和“spring-boot-starter-jdbc”有冲突,就把“spring-boot-starter-jdbc”的引入给删除了,随后启动就OK了。


对于初学者,处处是坑啊!

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值