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();
    }
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐