merge
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.xwbing.configuration;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.xwbing.domain.entity.model.DruidDataSourceModel;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 说明: 德鲁伊监控:druid/index.html
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DruidDataSourceModel.class)
|
||||
public class DruidConfig {
|
||||
@Resource
|
||||
private DruidDataSourceModel druidDataSourceModel;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DruidDataSource dataSource() {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl(druidDataSourceModel.getUrl());
|
||||
dataSource.setDriverClassName(druidDataSourceModel.getDriver());
|
||||
dataSource.setUsername(druidDataSourceModel.getUsername());
|
||||
dataSource.setPassword(druidDataSourceModel.getPassword());
|
||||
dataSource.setInitialSize(druidDataSourceModel.getInitSize());
|
||||
dataSource.setMinIdle(druidDataSourceModel.getMinIdle());
|
||||
dataSource.setMaxActive(druidDataSourceModel.getMaxActive());
|
||||
dataSource.setMaxWait(druidDataSourceModel.getMaxWait());
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(druidDataSourceModel.getTimeBetweenEvictionRunsMillis());
|
||||
dataSource.setMinEvictableIdleTimeMillis(druidDataSourceModel.getMinEvictableIdleTimeMillis());
|
||||
dataSource.setValidationQuery(druidDataSourceModel.getValidationQuery());
|
||||
dataSource.setTestWhileIdle(druidDataSourceModel.isTestWhileIdle());
|
||||
dataSource.setTestOnBorrow(druidDataSourceModel.isTestOnBorrow());
|
||||
dataSource.setTestOnReturn(druidDataSourceModel.isTestOnReturn());
|
||||
dataSource.setPoolPreparedStatements(druidDataSourceModel.isPoolPreparedStatements());
|
||||
dataSource.setMaxPoolPreparedStatementPerConnectionSize(druidDataSourceModel.getMaxPoolPreparedStatementPerConnectionSize());
|
||||
dataSource.setConnectionProperties(druidDataSourceModel.getConnectionProperties());
|
||||
dataSource.setUseGlobalDataSourceStat(druidDataSourceModel.isUseGlobalDataSourceStat());
|
||||
try {
|
||||
dataSource.setFilters(druidDataSourceModel.getFilters());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.xwbing.configuration;
|
||||
|
||||
import com.xwbing.util.captcha.CaptchaServlet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 说明: 统一的servlet配置
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
public class ServletConfig {
|
||||
private final Logger logger = LoggerFactory.getLogger(ServletConfig.class);
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean captchaServletRegistrationBean() {
|
||||
logger.info("注册验证码servlet ======================= ");
|
||||
CaptchaServlet captchaServlet = new CaptchaServlet();
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(captchaServlet);
|
||||
registration.setEnabled(true);
|
||||
registration.addUrlMappings("/servlet/captcha");
|
||||
return registration;
|
||||
}
|
||||
/********************************************/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xwbing.configuration;
|
||||
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import com.xwbing.util.captcha.CaptchaServlet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 说明: 统一的servlet/filter配置
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
public class ServletFilterConfig {
|
||||
private final Logger logger = LoggerFactory.getLogger(ServletFilterConfig.class);
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean captchaServlet() {
|
||||
logger.info("注册验证码servlet ======================= ");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new CaptchaServlet());
|
||||
registration.addUrlMappings("/captcha");
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServlet() {
|
||||
logger.info("注册druidServlet ======================= ");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
|
||||
registration.addUrlMappings("/druid/*");
|
||||
//添加初始化参数:initParams
|
||||
// registration.addInitParameter("allow", "127.0.0.1");//IP白名单(没有配置或者为空,则允许所有访问)
|
||||
// registration.addInitParameter("deny", "192.168.31.234");//IP黑名单(存在共同时,deny优先于allow)
|
||||
registration.addInitParameter("loginUsername", "admin");//用户名
|
||||
registration.addInitParameter("loginPassword", "123456");//密码
|
||||
registration.addInitParameter("resetEnable", "false");//禁用HTML页面上的“Reset All”功能
|
||||
return registration;
|
||||
}
|
||||
/*******************************************************/
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean webStatFilter() {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
|
||||
//映射swagger文档
|
||||
set.add("/doc");
|
||||
//验证码
|
||||
set.add("/servlet/captcha");
|
||||
set.add("/captcha");
|
||||
//swagger
|
||||
set.add("/v2/api-docs");
|
||||
set.add("/swagger-resources");
|
||||
|
||||
Reference in New Issue
Block a user