springcloud 整合 druid 阿里的数据库连接池

springcloud 整合 druid 阿里的数据库连接池

 1. 配置 pom

	    <!-- druid 数据库连接池  -->
	    <dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.1.12</version>
			<exclusions>  
		        <exclusion>  
		            <groupId>com.alibaba</groupId>  
		            <artifactId>jconsole</artifactId>  
		        </exclusion>  
		        <exclusion>  
		            <groupId>com.alibaba</groupId>  
		            <artifactId>tools</artifactId>  
		        </exclusion>  
		    </exclusions>
		</dependency>

2. 配置 application.properties

#druid连接池
spring.datasource.type: com.alibaba.druid.pool.DruidDataSource
#最大活跃数
spring.datasource.maxActive: 20
#初始化数量
spring.datasource.initialSize: 1
#最大连接等待超时时间
spring.datasource.maxWait: 60000
#打开PSCache,并且指定每个连接PSCache的大小
spring.datasource.poolPreparedStatements: true
spring.datasource.maxPoolPreparedStatementPerConnectionSize: 20
#通过connectionProperties属性来打开mergeSql功能;慢SQL记录
#connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
spring.datasource.minIdle: 1
spring.datasource.timeBetweenEvictionRunsMillis: 60000
spring.datasource.minEvictableIdleTimeMillis: 300000
spring.datasource.validationQuery: select 1 from dual
spring.datasource.testWhileIdle: true
spring.datasource.testOnBorrow: false
spring.datasource.testOnReturn: false
#配置监控统计拦截的filters,去掉后监控界面sql将无法统计,"wall"用于防火墙
filters: stat, wall, log4j

3.Config 配置类

 
 
/**
 * 说明:第一数据源配置
 * 作者:FH
 * from:fhadmin.cn
 */
@Configuration
@MapperScan(basePackages = MasterDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "masterSqlSessionFactory") //扫描 Mapper 接口并容器管理
public class MasterDataSourceConfig {
 
    static final String PACKAGE = "org.fh.mapper.dsno1";								//master 目录
    static final String MAPPER_LOCATION = "classpath:mybatis/dsno1/*/*.xml";			//扫描的 xml 目录
    static final String CONFIG_LOCATION = "classpath:mybatis/dsno1/mybatis-config.xml"; //自定义的mybatis config 文件位置
    static final String TYPE_ALIASES_PACKAGE = "org.fh.entity"; 						//扫描的 实体类 目录
 
    @Value("${datasource.no1.url}")
    private String url;
 
    @Value("${datasource.no1.username}")
    private String user;
 
    @Value("${datasource.no1.password}")
    private String password;
 
    @Value("${datasource.no1.driver-class-name}")
    private String driverClass;
 
    @Bean(name = "masterDataSource")
    @Primary
    public DataSource masterDataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(url);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        return dataSource;
    }
 
    @Bean(name = "masterTransactionManager")
    @Primary
    public DataSourceTransactionManager masterTransactionManager() {
        return new DataSourceTransactionManager(masterDataSource());
    }
 
    @Bean(name = "masterSqlSessionFactory")
    @Primary
    public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource)throws Exception {
        final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
        sessionFactory.setDataSource(masterDataSource);
        sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MasterDataSourceConfig.MAPPER_LOCATION));
        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(MasterDataSourceConfig.CONFIG_LOCATION));
        sessionFactory.setTypeAliasesPackage(MasterDataSourceConfig.TYPE_ALIASES_PACKAGE);
        return sessionFactory.getObject();
    }
}

 

  ​-----------------------------------------------------------------自定义表单
28. 定义模版:拖拽左侧表单元素到右侧区域,编辑表单元素,保存表单模版
29. 表单模版:编辑维护表单模版,复制表单模版,修改模版类型,预览表单模版
30. 我的表单:选择表单模版,编辑表单规则,是否上传图片、附件、开启富文本、挂靠流程开关等
31. 表单数据:从我的表单进去可增删改查表单数据,修改表单规则
32. 挂靠记录:记录表单数据和流程实例ID关联记录,可删除
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » springcloud 整合 druid 阿里的数据库连接池