第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Spring Boot,Spring Data JPA,帶有多個(gè)DataSources

Spring Boot,Spring Data JPA,帶有多個(gè)DataSources

qq_遁去的一_1 2019-09-02 08:31:49
我正在嘗試使用Spring Boot和Spring Data JPA將每個(gè)@Repositories連接到不同的DataSource。我使用以下內(nèi)容http://xantorohara.blogspot.com/2013/11/spring-boot-jdbc-with-multiple.html作為參考。以下是我試圖使用Spring Data JPA實(shí)現(xiàn)類似解決方案時(shí)使用的代碼。CustomerDbConfig.java(第一個(gè)數(shù)據(jù)源連接)@Configuration@EnableJpaRepositories(        entityManagerFactoryRef = "orderEntityManager",        transactionManagerRef = "orderTransactionManager",        basePackages = {"com.mm.repository.customer"})public class CustomerDbConfig {    @Bean(name = "customerEntityManager")    public LocalContainerEntityManagerFactoryBean entityManagerFactory(){        LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();        em.setDataSource(dataSource());        em.setPackagesToScan(new String[] {"com.mm.domain.customer"});        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();        em.setJpaVendorAdapter(vendorAdapter);        em.setJpaProperties(additionalJpaProperties());        em.setPersistenceUnitName("customerPersistence");        em.setPackagesToScan("com.mm.domain.customer");        return em;    }    Properties additionalJpaProperties(){        Properties properties = new Properties();        properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");        properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");        properties.setProperty("hibernate.show_sql", "true");        return properties;    }    @Bean    public DataSource dataSource(){        return DataSourceBuilder.create()                .url("jdbc:h2:mem:customer:H2")                .driverClassName("org.h2.Driver")                .username("sa")                .password("")                .build();    }   
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1461 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)