去除druid数据库连接池,使用spring支持的hikari
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<Object> {
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public HttpMessageConverters custHttpMessageConverter() {
|
||||
public HttpMessageConverters fast() {
|
||||
return new HttpMessageConverters(new FastJsonHttpMessageConverter());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Servlet> 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<Filter> filterRegistrationBean = new FilterRegistrationBean<>(new WebStatFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
Reference in New Issue
Block a user