diff --git a/pom.xml b/pom.xml index 7cf44e76..5628ab37 100644 --- a/pom.xml +++ b/pom.xml @@ -123,11 +123,9 @@ spring-boot-starter-security - - com.alibaba - druid-spring-boot-starter - 1.2.11 + org.springframework.boot + spring-boot-starter-jdbc @@ -294,7 +292,7 @@ org.springframework.boot spring-boot-maven-plugin - 2.3.5.RELEASE + 2.7.2 true diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index eab22079..886d6fa1 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp; -import com.genersoft.iot.vmp.conf.druid.EnableDruidSupport; import com.genersoft.iot.vmp.utils.GitUtil; import com.genersoft.iot.vmp.utils.SpringBeanFactory; import org.slf4j.Logger; @@ -25,7 +24,6 @@ import java.util.Collections; @ServletComponentScan("com.genersoft.iot.vmp.conf") @SpringBootApplication @EnableScheduling -@EnableDruidSupport public class VManageBootstrap extends SpringBootServletInitializer { private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java index 05f74816..c8b84fe9 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java @@ -10,14 +10,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; -import java.util.List; - /** * 全局统一返回结果 * @author lin @@ -63,7 +60,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice { * @return */ @Bean - public HttpMessageConverters custHttpMessageConverter() { + public HttpMessageConverters fast() { return new HttpMessageConverters(new FastJsonHttpMessageConverter()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/druid/DruidConfiguration.java b/src/main/java/com/genersoft/iot/vmp/conf/druid/DruidConfiguration.java deleted file mode 100644 index 12f6e636..00000000 --- a/src/main/java/com/genersoft/iot/vmp/conf/druid/DruidConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.genersoft.iot.vmp.conf.druid; - -import com.alibaba.druid.support.http.StatViewServlet; -import com.alibaba.druid.support.http.WebStatFilter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; - -import javax.servlet.Filter; -import javax.servlet.Servlet; - -/** - * druid监控配置 - * @author - */ -public class DruidConfiguration { - - @Value("${rj-druid-manage.allow:127.0.0.1}") - private String allow; - - @Value("${rj-druid-manage.deny:}") - private String deny; - - @Value("${rj-druid-manage.loginUsername:admin}") - private String loginUsername; - - @Value("${rj-druid-manage.loginPassword:admin}") - private String loginPassword; - - @Value("${rj-druid-manage.resetEnable:false}") - private String resetEnable; - - /** - * druid监控页面开启 - */ - @Bean - public ServletRegistrationBean druidServlet() { - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*"); - // IP白名单 - servletRegistrationBean.addInitParameter("allow", allow); - // IP黑名单(共同存在时,deny优先于allow) - servletRegistrationBean.addInitParameter("deny", deny); - //控制台管理用户 - servletRegistrationBean.addInitParameter("loginUsername", loginUsername); - servletRegistrationBean.addInitParameter("loginPassword", loginPassword); - //是否能够重置数据 禁用HTML页面上的“Reset All”功能 - servletRegistrationBean.addInitParameter("resetEnable", resetEnable); - return servletRegistrationBean; - } - - /** - * druid url监控配置 - */ - @Bean - public FilterRegistrationBean filterRegistrationBean() { - FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>(new WebStatFilter()); - filterRegistrationBean.addUrlPatterns("/*"); - filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); - return filterRegistrationBean; - } - - -} \ No newline at end of file diff --git a/src/main/java/com/genersoft/iot/vmp/conf/druid/EnableDruidSupport.java b/src/main/java/com/genersoft/iot/vmp/conf/druid/EnableDruidSupport.java deleted file mode 100644 index 5fd710be..00000000 --- a/src/main/java/com/genersoft/iot/vmp/conf/druid/EnableDruidSupport.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.genersoft.iot.vmp.conf.druid; - -import org.springframework.boot.web.servlet.ServletComponentScan; -import org.springframework.context.annotation.Import; - -import java.lang.annotation.*; - -/** - * druid监控支持注解 - * - * @author - * {@link DruidConfiguration} druid监控页面安全配置支持 - * {@link ServletComponentScan} druid监控页面需要扫描servlet - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@Import({ - DruidConfiguration.class, -}) -@ServletComponentScan -public @interface EnableDruidSupport { -} diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 8bc4d957..bfa4bcf6 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -30,44 +30,19 @@ spring: poolMaxWait: 5 # [必选] jdbc数据库配置 datasource: - type: com.alibaba.druid.pool.DruidDataSource + type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/wvp2?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true username: root password: root123 - druid: + hikari: + connection-timeout: 20000 # 是客户端等待连接池连接的最大毫秒数 initialSize: 10 # 连接池初始化连接数 - maxActive: 200 # 连接池最大连接数 - minIdle: 5 # 连接池最小空闲连接数 - maxWait: 60000 # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁。 - keepAlive: true # 连接池中的minIdle数量以内的连接,空闲时间超过minEvictableIdleTimeMillis,则会执行keepAlive操作。 - validationQuery: select 1 # 检测连接是否有效sql,要求是查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。 - testWhileIdle: true # 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 - testOnBorrow: false # 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 - testOnReturn: false # 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 - poolPreparedStatements: false # 是否開啟PSCache,並且指定每個連線上PSCache的大小 - timeBetweenEvictionRunsMillis: 60000 # 配置間隔多久才進行一次檢測,檢測需要關閉的空閒連線,單位是毫秒 - minEvictableIdleTimeMillis: 300000 # 配置一個連線在池中最小生存的時間,單位是毫秒 - filters: stat,slf4j # 配置监控统计拦截的filters,监控统计用的filter:sta, 日志用的filter:log4j - useGlobalDataSourceStat: true # 合并多个DruidDataSource的监控数据 - # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 - connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=1000 - #stat-view-servlet.url-pattern: /admin/druid/* + maximum-pool-size: 200 # 连接池最大连接数 + minimum-idle: 5 # 连接池最小空闲连接数 + idle-timeout: 300000 # 允许连接在连接池中空闲的最长时间(以毫秒为单位) + max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) -# druid管理监控页面的一些配置 -rj-druid-manage: - allow: # 访问druid监控页面的IP白名单 - deny: 192.168.1.100 # 访问druid监控页面IP黑名单 - loginUsername: rjAdmin # 访问druid监控页面账号 - loginPassword: rj@2022 # 访问druid监控页面密码 - -#mybatis: -# configuration: -# # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 -# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl -# # 返回类型为Map,显示null对应的字段 -# call-setters-on-nulls: true -## [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 server: