本文整理匯總了Java中com.alibaba.druid.support.http.StatViewServlet類的典型用法代碼示例。如果您正苦於以下問題:Java StatViewServlet類的具體用法?Java StatViewServlet怎麽用?Java StatViewServlet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StatViewServlet類屬於com.alibaba.druid.support.http包,在下文中一共展示了StatViewServlet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registrationBean
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
/**
* 注冊ServletRegistrationBean
* @return
*/
@Bean
public ServletRegistrationBean registrationBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
/** 初始化參數配置,initParams**/
//白名單
bean.addInitParameter("allow", "127.0.0.1");
//IP黑名單 (存在共同時,deny優先於allow) : 如果滿足deny的話提示:Sorry, you are not permitted to view this page.
bean.addInitParameter("deny", "192.168.1.73");
//登錄查看信息的賬號密碼.
bean.addInitParameter("loginUsername", "admin");
bean.addInitParameter("loginPassword", "admin");
//是否能夠重置數據.
bean.addInitParameter("resetEnable", "false");
return bean;
}
示例2: servletRegistrationBean
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
/**
* Druid 提供了一個 StatViewServlet 用於展示 Druid 的統計信息
* 這個 StatViewServlet 的用途包括:
* 1. 提供監控信息展示的 HTML 頁麵
* 2. 提供監控信息的 JSON API
*/
@Bean
public ServletRegistrationBean servletRegistrationBean(DruidDataSourceProperties druidDataSourceProperties) {
log.debug("druid stat-view-servlet init...");
DruidStatViewServletProperties properties = druidDataSourceProperties.getStatViewServlet();
ServletRegistrationBean registration = new ServletRegistrationBean();
StatViewServlet statViewServlet = new StatViewServlet();
registration.setServlet(statViewServlet);
registration.addUrlMappings(properties.getUrlMappings());
if (!StringUtils.isEmpty(properties.getLoginUsername())) {
registration.addInitParameter("loginUsername", properties.getLoginUsername());
}
if (!StringUtils.isEmpty(properties.getLoginPassword())) {
registration.addInitParameter("loginPassword", properties.getLoginPassword());
}
if (!StringUtils.isEmpty(properties.getAllow())) {
registration.addInitParameter("allow", properties.getAllow());
}
if (!StringUtils.isEmpty(properties.getDeny())) {
registration.addInitParameter("deny", properties.getDeny());
}
registration.addInitParameter("resetEnable", Boolean.toString(properties.isResetEnable()));
return registration;
}
示例3: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
@ConfigurationProperties(DruidServletProperties.DRUID_SERVLET_PREFIX)
public ServletRegistrationBean druidServlet(DruidServletProperties properties) {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings(properties.getUrlMappings());
if(properties.getAllow() !=null){
reg.addInitParameter("allow", properties.getAllow()); // IP白名單 (沒有配置或者為空,則允許所有訪問)
}
if(properties.getDeny() !=null){
reg.addInitParameter("deny", properties.getDeny()); //IP黑名單 (存在共同時,deny優先於allow)
}
if(properties.getLoginUsername() !=null){
reg.addInitParameter("loginUsername", properties.getLoginUsername()); //用戶名
}
if(properties.getLoginPassword() !=null){
reg.addInitParameter("loginPassword", properties.getLoginPassword()); // 密碼
}
if(properties.getResetEnable() !=null){
reg.addInitParameter("resetEnable", properties.getResetEnable().toString());// 禁用HTML頁麵上的“Reset All”功能
}
return reg;
}
示例4: druidStatViewServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
/**
* 數據源監控注冊一個StatViewServlet
*
* @return
*/
@Bean
public ServletRegistrationBean druidStatViewServlet(){
//注冊監控地址
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//白名單
servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//IP黑名單 (存在共同時,deny優先於allow) : 如果滿足deny的話提示:Sorry, you are not permitted to view this page.
servletRegistrationBean.addInitParameter("deny","192.168.1.73");
//登錄查看信息的賬號密碼.
servletRegistrationBean.addInitParameter("loginUsername","admin");
servletRegistrationBean.addInitParameter("loginPassword","123456");
//是否能夠重置數據.
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例5: registrationBean
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
/**
* 注冊ServletRegistrationBean
* @return
*/
@Bean
public ServletRegistrationBean registrationBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
/** 初始化參數配置,initParams**/
//白名單
bean.addInitParameter("allow", "127.0.0.1");
//IP黑名單 (存在共同時,deny優先於allow) : 如果滿足deny的話提示:Sorry, you are not permitted to view this page.
bean.addInitParameter("deny", "192.168.1.73");
//登錄查看信息的賬號密碼.
bean.addInitParameter("loginUsername", "admin2");
bean.addInitParameter("loginPassword", "123");
//是否能夠重置數據.
bean.addInitParameter("resetEnable", "false");
return bean;
}
示例6: registerServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean registerServlet(){
ServletRegistrationBean statViewServletRegistrationBean =
new ServletRegistrationBean(dispatchDruidServlet(), "/druid/*");
/*
* According to the definition of StatViewServlet, the white-list of druid StatViewServlet
* can be specifed with the format as "xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy" to limit the access to
* the StatViewServlet.
*/
statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "127.0.0.1");
statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_USERNAME, "admin");
statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_PASSWORD, "password");
return statViewServletRegistrationBean;
}
示例7: statViewServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
@Order
public ServletRegistrationBean statViewServlet() {
StatViewServlet servlet = new StatViewServlet();
ServletRegistrationBean bean = new ServletRegistrationBean(servlet, "/druid/*");
return bean;
}
示例8: statViewServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean statViewServlet(){
//創建servlet注冊實體
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//設置ip白名單
// servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//設置ip黑名單,如果allow與deny共同存在時,deny優先於allow
// servletRegistrationBean.addInitParameter("deny","192.168.0.19");
//設置控製台管理用戶
servletRegistrationBean.addInitParameter("loginUsername","lpj");
servletRegistrationBean.addInitParameter("loginPassword","123");
//是否可以重置數據
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例9: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("allow", "127.0.0.1");//允許訪問地址,不填則全允許,填了隻允許
// reg.addInitParameter("deny", "127.0.0.1");
reg.addInitParameter("loginUsername", dbConfigProperties.getDruidVisitName());
reg.addInitParameter("loginPassword", dbConfigProperties.getDruidVisitPwd());
return reg;
}
示例10: statViewServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean statViewServlet(){
//創建servlet注冊實體
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//設置ip白名單
servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//設置ip黑名單,如果allow與deny共同存在時,deny優先於allow
servletRegistrationBean.addInitParameter("deny","192.168.0.19");
//設置控製台管理用戶
servletRegistrationBean.addInitParameter("loginUsername","druid");
servletRegistrationBean.addInitParameter("loginPassword","123456");
//是否可以重置數據
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例11: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
servletRegistrationBean.setServlet(new StatViewServlet());
servletRegistrationBean.addUrlMappings("/druid/*");
return servletRegistrationBean;
}
示例12: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("loginUsername", "admin");
reg.addInitParameter("loginPassword", "admin123");
return reg;
}
示例13: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidServlet() {
logger.info("init Druid Servlet Configuration ");
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// IP白名單
servletRegistrationBean.addInitParameter("allow", "");
// IP黑名單(共同存在時,deny優先於allow)
// servletRegistrationBean.addInitParameter("deny", "");
//控製台管理用戶
servletRegistrationBean.addInitParameter("loginUsername", "admin");
servletRegistrationBean.addInitParameter("loginPassword", "admin");
//是否能夠重置數據 禁用HTML頁麵上的“Reset All”功能
servletRegistrationBean.addInitParameter("resetEnable", "false");
return servletRegistrationBean;
}
示例14: druidStatViewServletBean
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidStatViewServletBean() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), env.getProperty("druid.urlMapper"));
Map<String,String> params = new HashMap<>();
params.put("loginUsername",env.getProperty("druid.loginUsername"));
params.put("loginPassword",env.getProperty("druid.loginPassword"));
params.put("resetEnable",env.getProperty("druid.resetEnable"));
servletRegistrationBean.setInitParameters(params);
return servletRegistrationBean;
}
示例15: druidServlet
import com.alibaba.druid.support.http.StatViewServlet; //導入依賴的package包/類
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
// servletRegistrationBean.addInitParameter("deny", "");
servletRegistrationBean.addInitParameter("username", "admin");
servletRegistrationBean.addInitParameter("password", "123456");
return servletRegistrationBean;
}