當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Boot集成Druid监控
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot集成Druid监控
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
package com.xxxxxxx.framework.datasource.druid;import com.alibaba.druid.support.http.WebStatFilter;import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;/*** druid過濾器.*/
@WebFilter(filterName = "druidWebStatFilter", urlPatterns = "/*", initParams = {// 忽略資源@WebInitParam(name = "exclusions", value = "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*") })
public class DruidStatFilter extends WebStatFilter {
}
DruidStatFilter.Java類
package com.xxxxxxx.framework.datasource.druid; import com.alibaba.druid.support.http.StatViewServlet;import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet;@WebServlet(urlPatterns = "/druid/*", initParams = {// IP白名單 (沒有配置或者為空,則允許所有訪問)@WebInitParam(name = "allow", value = ""),// IP黑名單 (存在共同時,deny優先于allow)@WebInitParam(name = "deny", value = "192.168.1.100"), // // 用戶名 // @WebInitParam(name = "loginUsername", value = "admin"), // // 密碼 // @WebInitParam(name = "loginPassword", value = "admin"),// 禁用HTML頁面上的“Reset All”功能@WebInitParam(name = "resetEnable", value = "false") }) @SuppressWarnings("serial") public class DruidStatServlet extends StatViewServlet {}?
DruidStatServlet.Java類,如果需要登錄時候有用戶名密碼,可以設置
@ServletComponentScan(basePackages ={"com.xxxxxxx.framework.datasource.druid"} ) @SpringBootApplication@EnableEncryptableProperties public class ApiServiceApp {public static void main(String[] args) throws Exception {ApplicationContext ac = SpringApplication.run(ApiServiceApp.class, args);ProjectUtil.afterRun(ac, true, true);} }最后在main啟動處加掃描
@ServletComponentScan(basePackages ={"com.xxxxxxx.framework.datasource.druid"} )
?
總結
以上是生活随笔為你收集整理的Spring Boot集成Druid监控的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Maven添加Oracle驱动及依赖
- 下一篇: dump查询Java 状态