diff --git a/backend/src/main/java/io/metersphere/config/MybatisConfig.java b/backend/src/main/java/io/metersphere/config/DatabaseConfig.java similarity index 63% rename from backend/src/main/java/io/metersphere/config/MybatisConfig.java rename to backend/src/main/java/io/metersphere/config/DatabaseConfig.java index 6495f83b93..77c5290017 100644 --- a/backend/src/main/java/io/metersphere/config/MybatisConfig.java +++ b/backend/src/main/java/io/metersphere/config/DatabaseConfig.java @@ -1,6 +1,8 @@ package io.metersphere.config; +import com.fit2cloud.quartz.anno.QuartzDataSource; import com.github.pagehelper.PageInterceptor; +import com.zaxxer.hikari.HikariDataSource; import io.metersphere.base.domain.ApiTestReportDetail; import io.metersphere.base.domain.AuthSource; import io.metersphere.base.domain.FileContent; @@ -11,10 +13,15 @@ import io.metersphere.interceptor.MybatisInterceptor; import io.metersphere.interceptor.UserDesensitizationInterceptor; 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; @@ -22,7 +29,7 @@ import java.util.Properties; @Configuration @MapperScan(basePackages = {"io.metersphere.base.mapper", "io.metersphere.xpack.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory") @EnableTransactionManagement -public class MybatisConfig { +public class DatabaseConfig { @Bean @ConditionalOnMissingBean @@ -55,4 +62,30 @@ public class MybatisConfig { 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(); + } + + } \ No newline at end of file diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 4b8b9a1f33..0e57296c79 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -11,6 +11,18 @@ spring.datasource.hikari.pool-name=DatebookHikariCP spring.datasource.hikari.max-lifetime=1800000 spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.connection-test-query=SELECT 1 +# +spring.datasource.quartz.url=${spring.datasource.url} +spring.datasource.quartz.username=${spring.datasource.username} +spring.datasource.quartz.password=${spring.datasource.password} +spring.datasource.quartz.hikari.maximum-pool-size=50 +spring.datasource.quartz.hikari.auto-commit=true +spring.datasource.quartz.hikari.idle-timeout=10000 +spring.datasource.quartz.hikari.pool-name=DatebookHikariCP +spring.datasource.quartz.hikari.max-lifetime=1800000 +spring.datasource.quartz.hikari.connection-timeout=30000 +spring.datasource.quartz.hikari.connection-test-query=SELECT 1 +# #kafka spring.kafka.bootstrap-servers=${kafka.bootstrap-servers} spring.kafka.consumer.group-id=metersphere_group_id @@ -71,6 +83,7 @@ jmeter.home=/opt/jmeter # quartz quartz.enabled=true quartz.scheduler-name=msServerJob +quartz.thread-count=30 # file upload spring.servlet.multipart.max-file-size=500MB spring.servlet.multipart.max-request-size=500MB