From 7201205af85508421037119ba66b3a6a48de61ec Mon Sep 17 00:00:00 2001 From: guang <guang@guang.com> Date: 星期六, 06 五月 2023 11:58:57 +0800 Subject: [PATCH] 分布及druid --- src/main/java/com/hx/other/service/config/DataSourceConfig.java | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/hx/other/service/config/DataSourceConfig.java b/src/main/java/com/hx/other/service/config/DataSourceConfig.java index 0912e34..ba495ae 100644 --- a/src/main/java/com/hx/other/service/config/DataSourceConfig.java +++ b/src/main/java/com/hx/other/service/config/DataSourceConfig.java @@ -1,13 +1,27 @@ package com.hx.other.service.config; +import com.alibaba.druid.pool.DruidDataSource; +import com.github.pagehelper.PageInterceptor; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; 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.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; import javax.sql.DataSource; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; /** * 鏁版嵁婧愰厤缃� @@ -16,6 +30,9 @@ */ @Configuration public class DataSourceConfig { + + @Value("${mybatis.mapperLocations}") + private String writeMapperLocatioin; @Bean(name = "readDataSource") @Qualifier("readDataSource") @@ -31,6 +48,6 @@ @Primary public DataSource writeDataSource() { - return DataSourceBuilder.create().build(); + return new DruidDataSource(); } } -- Gitblit v1.8.0