解决A component required a bean named ‘entityManagerFactory‘ that could not be found
三步走2.1检查依赖2.2删除依赖2.3检查DB配置类
·
SpringBoot 整合 Spring Data JPA 报警
1.问题
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
2.三步走
2.1检查依赖
jpa不要带版本号
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
2.2删除依赖
\repository\org\hibernate\hibernate-core
然后刷新Maven,会重新下载
2.3检查DB配置类
- spring.datasource.type=com.zaxxer.hikari.HikariDataSource
- spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
- spring.datasource.jdbc-url=jdbc:oracle:thin:@//xxxxxxx
- spring.datasource.username=study123456
- spring.datasource.password=study123456
- spring.jpa.hibernate.ddl-auto=update
- spring.jpa.show-sql=true
@Configuration
public class DataSourceConfig {
@Bean(name = "dataSource1")
@Qualifier("dataSource1")
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource1(){
return DataSourceBuilder.create().build();
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)