build: sdk 放置通用配置
This commit is contained in:
parent
c0e5a9b45f
commit
a38157faae
|
@ -1,4 +1,4 @@
|
||||||
package io.metersphere.config;
|
package io.metersphere.sdk.config;
|
||||||
|
|
||||||
import com.fit2cloud.quartz.anno.QuartzDataSource;
|
import com.fit2cloud.quartz.anno.QuartzDataSource;
|
||||||
import com.github.pagehelper.PageInterceptor;
|
import com.github.pagehelper.PageInterceptor;
|
|
@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration;
|
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
|
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@SpringBootApplication(exclude = {
|
@SpringBootApplication(exclude = {
|
||||||
QuartzAutoConfiguration.class,
|
QuartzAutoConfiguration.class,
|
||||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
MybatisAutoConfiguration.class
|
MybatisAutoConfiguration.class
|
||||||
})
|
})
|
||||||
@ServletComponentScan
|
@ServletComponentScan
|
||||||
|
@ComponentScan(basePackages = {"io.metersphere.sdk", "io.metersphere.project"})
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
package io.metersphere.project.config;
|
|
||||||
|
|
||||||
import com.fit2cloud.quartz.anno.QuartzDataSource;
|
|
||||||
import com.github.pagehelper.PageInterceptor;
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
|
||||||
import io.metersphere.sdk.interceptor.MybatisInterceptor;
|
|
||||||
import io.metersphere.sdk.interceptor.UserDesensitizationInterceptor;
|
|
||||||
import io.metersphere.sdk.util.MybatisInterceptorConfig;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
|
||||||
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.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@MapperScan(basePackages = {"io.metersphere.*.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")
|
|
||||||
@EnableTransactionManagement
|
|
||||||
public class MybatisConfig {
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public PageInterceptor pageInterceptor() {
|
|
||||||
PageInterceptor pageInterceptor = new PageInterceptor();
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.setProperty("helperDialect", "mysql");
|
|
||||||
properties.setProperty("rowBoundsWithCount", "true");
|
|
||||||
properties.setProperty("reasonable", "true");
|
|
||||||
properties.setProperty("offsetAsPageNum", "true");
|
|
||||||
properties.setProperty("pageSizeZero", "true");
|
|
||||||
pageInterceptor.setProperties(properties);
|
|
||||||
return pageInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public MybatisInterceptor dbInterceptor() {
|
|
||||||
MybatisInterceptor interceptor = new MybatisInterceptor();
|
|
||||||
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
|
||||||
// configList.add(new MybatisInterceptorConfig(FileContent.class, "file", CompressUtils.class, "zip", "unzip"));
|
|
||||||
interceptor.setInterceptorConfigList(configList);
|
|
||||||
return interceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public UserDesensitizationInterceptor userDesensitizationInterceptor() {
|
|
||||||
return new UserDesensitizationInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.hikari")
|
|
||||||
public DataSource dataSource(DataSourceProperties properties) {
|
|
||||||
return DataSourceBuilder.create(properties.getClassLoader()).type(HikariDataSource.class)
|
|
||||||
.driverClassName(properties.determineDriverClassName())
|
|
||||||
.url(properties.determineUrl())
|
|
||||||
.username(properties.determineUsername())
|
|
||||||
.password(properties.determinePassword())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.quartz.hikari")
|
|
||||||
@QuartzDataSource
|
|
||||||
public DataSource quartzDataSource(DataSourceProperties properties) {
|
|
||||||
return DataSourceBuilder.create(properties.getClassLoader()).type(HikariDataSource.class)
|
|
||||||
.driverClassName(properties.determineDriverClassName())
|
|
||||||
.url(properties.determineUrl())
|
|
||||||
.username(properties.determineUsername())
|
|
||||||
.password(properties.determinePassword())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package io.metersphere.system.config;
|
|
||||||
|
|
||||||
import com.fit2cloud.quartz.anno.QuartzDataSource;
|
|
||||||
import com.github.pagehelper.PageInterceptor;
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
|
||||||
import io.metersphere.sdk.interceptor.MybatisInterceptor;
|
|
||||||
import io.metersphere.sdk.interceptor.UserDesensitizationInterceptor;
|
|
||||||
import io.metersphere.sdk.util.MybatisInterceptorConfig;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
|
||||||
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.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@MapperScan(basePackages = {"io.metersphere.*.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")
|
|
||||||
@EnableTransactionManagement
|
|
||||||
public class MybatisConfig {
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public PageInterceptor pageInterceptor() {
|
|
||||||
PageInterceptor pageInterceptor = new PageInterceptor();
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.setProperty("helperDialect", "mysql");
|
|
||||||
properties.setProperty("rowBoundsWithCount", "true");
|
|
||||||
properties.setProperty("reasonable", "true");
|
|
||||||
properties.setProperty("offsetAsPageNum", "true");
|
|
||||||
properties.setProperty("pageSizeZero", "true");
|
|
||||||
pageInterceptor.setProperties(properties);
|
|
||||||
return pageInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public MybatisInterceptor dbInterceptor() {
|
|
||||||
MybatisInterceptor interceptor = new MybatisInterceptor();
|
|
||||||
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
|
||||||
// configList.add(new MybatisInterceptorConfig(FileContent.class, "file", CompressUtils.class, "zip", "unzip"));
|
|
||||||
interceptor.setInterceptorConfigList(configList);
|
|
||||||
return interceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public UserDesensitizationInterceptor userDesensitizationInterceptor() {
|
|
||||||
return new UserDesensitizationInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.hikari")
|
|
||||||
public DataSource dataSource(DataSourceProperties properties) {
|
|
||||||
return DataSourceBuilder.create(properties.getClassLoader()).type(HikariDataSource.class)
|
|
||||||
.driverClassName(properties.determineDriverClassName())
|
|
||||||
.url(properties.determineUrl())
|
|
||||||
.username(properties.determineUsername())
|
|
||||||
.password(properties.determinePassword())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.quartz.hikari")
|
|
||||||
@QuartzDataSource
|
|
||||||
public DataSource quartzDataSource(DataSourceProperties properties) {
|
|
||||||
return DataSourceBuilder.create(properties.getClassLoader()).type(HikariDataSource.class)
|
|
||||||
.driverClassName(properties.determineDriverClassName())
|
|
||||||
.url(properties.determineUrl())
|
|
||||||
.username(properties.determineUsername())
|
|
||||||
.password(properties.determinePassword())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue