Commit 2968978b authored by suntao's avatar suntao

Merge branch 'db-list' into sql

parents af0491b0 21b3e973
package cn.quantgroup.cashloanflowboss.core.configuration.data;
import cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowBossPubConfDataSource;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"cn.quantgroup"}, entityManagerFactoryRef = "bossEntityManager", transactionManagerRef = "bossTransactionManager", includeFilters = @ComponentScan.Filter(CashLoanFlowBossPubConfDataSource.class))
public class CashLoanFlowBossPubConfDataSourceConfiguration {
@Value("${data.boss.url}")
private String jdbcUrl;
@Value("${data.boss.password}")
private String password;
@Value("${data.boss.username}")
private String user;
private String uniquename = "bossDSPub";
@Value("${data.boss.pool-size}")
private Integer poolSize;
//@Primary
@Bean(name = "bossPubDataSource")
@ConfigurationProperties(prefix = "data.boss.pub")
public DataSource createDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(200);
source.setMinIdle(10);
source.setInitialSize(10);
source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000);
source.setValidationQuery("SELECT 'x'");
source.setTestWhileIdle(true);
source.setTestOnBorrow(false);
source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE);
return source;
}
@Primary
@Bean(name = "bossEntityManager")
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.api")
.persistenceUnit(uniquename)
.build();
}
@Primary
@Bean(name = "bossTransactionManager")
public PlatformTransactionManager transactionManager(@Qualifier("bossEntityManager") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
package cn.quantgroup.cashloanflowboss.core.persistence;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by WeiWei on 2019/8/9.
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CashLoanFlowBossPubConfDataSource {
}
package cn.quantgroup.cashloanflowboss.spi.clf.service;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment