ClickhouseConfig.java
@Configuration @EntityScan(basePackages = "test.entity.clickhouse") @EnableJpaRepositories( basePackages = "test.repository.clickhouse", entityManagerFactoryRef = "clickhouseEntityManagerFactory", transactionManagerRef = "clickhouseTransactionManager", repositoryBaseClass = BaseRepositoryImpl.class) // enableDefaultTransactions = false) @EnableTransactionManagement public class ClickhouseConfig { @Autowired @Qualifier("clickhouseDataSource") private DataSource dataSource; @Autowired @Qualifier("vendorClickhouseProperties") private Map<String, Object> vendorProperties; @Bean(name = "clickhouseEntityManagerFactory") public LocalContainerEntityManagerFactoryBean clickhouseEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder .dataSource(dataSource) .properties(vendorProperties) .packages("com.zcunsoft.tracking.report.entity.clickhouse") .persistenceUnit("clickhousePersistenceUnit") .build(); } @Bean(name = "clickhouseEntityManager") public EntityManager entityManager(EntityManagerFactoryBuilder builder) { return clickhouseEntityManagerFactory(builder).getObject().createEntityManager(); } @Bean(name = "clickhouseTransactionManager") PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder) { return new JpaTransactionManager(clickhouseEntityManagerFactory(builder).getObject()); } @Bean(name = "clickHouseJdbcTemplate") public NamedParameterJdbcTemplate clickHouseJdbcTemplate( @Qualifier("clickhouseDataSource") DataSource dataSource) { return new NamedParameterJdbcTemplate(dataSource); } }
标签:hibernate,springboot,数据源,builder,clickhouseEntityManagerFactory,Bean,dataSource, From: https://www.cnblogs.com/merseyalma/p/17174668.html