《JPA》'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.

springboot配置双数据源报错

Description:

Parameter 0 of method entityManagerFactoryCms in com.topsoft.demo.config.jpa.JpaDataSourceConfig required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' in your configuration.

 关键点在 @Primary ,   指定一个主数据源.

    @Bean(name = "cmsDataSource")
    @Qualifier("cmsDataSource")
    @ConfigurationProperties(prefix="spring.cms.datasource")
    @Primary
    public DataSource cmsDataSource() {
    	HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl(properties.getUrl());
        dataSource.setUsername(properties.getUsername());
        dataSource.setPassword(properties.getPassword());
        dataSource.setDriverClassName(properties.getDriverClassName());
        return dataSource;
    }

 

你可能感兴趣的:(java,springboot)