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

编程知识 更新时间:2023-05-02 05:35:29

报错名称


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.

报错原因 用了spring-boot-starter-data-jpa 同时 springbootApplication注解为:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class )

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

解决方案1

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class , HibernateJpaAutoConfiguration.class})

方案2
@SpringBootApplication()


更多推荐

springboot报错“Consider revisiting the conditions above or defining a bean of type

本文发布于:2023-04-26 07:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/49785cee5423c7f954c0e3ea7b14c42c.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   conditions   revisiting   springboot   defining

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104710文章数
  • 26220阅读数
  • 0评论数