SpringBoot监控Actuator,关闭redis监测

发布时间 2023-04-25 11:03:05作者: 何苦->

当我们导入了spring-boot-starter-actuator这个依赖后, SpringBoot会默认去监测一些信息。其中就包括redis、 会根据redis的默认初始配置, localhost:6379 尝试连接redis。如果我们没有用到redis, 启动就会报错

 <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
      <version>2.2.1.RELEASE</version>
   </dependency>

比如我在使用SpringBoot项目的时候,其中内置了Actuator的依赖, 启动报错

D:\tools\jdk1.8.0_281\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:5513,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\ThinkPad\AppData\Local\JetBrains\IntelliJIdea2020.3\captureAgent\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\ThinkPad\AppData\Local\Temp\idea_classpath421370888 com.ssjf.activiti.actest.ActestApplication
Connected to the target VM, address: '127.0.0.1:5513', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.6)

2023-04-25 10:35:58.779 [main] INFO  com.ssjf.activiti.actest.ActestApplication - Starting ActestApplication using Java 1.8.0_281 on Yan with PID 53488 (E:\www\java\work\actest\target\classes started by Lenovo in E:\www\java\work\actest)
2023-04-25 10:35:58.777 [background-preinit] INFO  org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.2.0.Final
2023-04-25 10:35:58.783 [main] INFO  com.ssjf.activiti.actest.ActestApplication - The following profiles are active: dev
2023-04-25 10:35:59.314 [main] INFO  o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor - For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-04-25 10:36:02.073 [main] INFO  o.s.d.r.config.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
2023-04-25 10:36:02.080 [main] INFO  o.s.d.r.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-04-25 10:36:02.224 [main] INFO  o.s.d.r.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 44 ms. Found 0 Redis repository interfaces.
2023-04-25 10:36:02.620 [main] INFO  o.springframework.cloud.context.scope.GenericScope - BeanFactory id=45800990-b54f-3afe-8dda-ba277abf28f1
2023-04-25 10:36:03.222 [main] INFO  o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8218 (http)
2023-04-25 10:36:03.233 [main] INFO  org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8218"]
2023-04-25 10:36:03.234 [main] INFO  org.apache.catalina.core.StandardService - Starting service [Tomcat]
2023-04-25 10:36:03.234 [main] INFO  org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.54]
2023-04-25 10:36:03.393 [main] INFO  o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2023-04-25 10:36:03.394 [main] INFO  o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 4080 ms
2023-04-25 10:36:06.316 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2023-04-25 10:36:06.567 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2023-04-25 10:36:07.408 [main] INFO  o.a.e.c.DefaultActiviti5CompatibilityHandlerFactory - Activiti 5 compatibility handler implementation not found or error during instantiation : org.activiti.compatibility.DefaultActiviti5CompatibilityHandler. Activiti 5 backwards compatibility disabled.
2023-04-25 10:36:07.540 [main] INFO  org.activiti.engine.impl.ProcessEngineImpl - ProcessEngine default created
2023-04-25 10:36:07.541 [main] INFO  o.a.e.impl.asyncexecutor.DefaultAsyncJobExecutor - Starting up the default async job executor [org.activiti.spring.SpringAsyncExecutor].
2023-04-25 10:36:07.542 [Thread-26] INFO  o.a.e.impl.asyncexecutor.AcquireTimerJobsRunnable - {} starting to acquire async jobs due
2023-04-25 10:36:07.542 [Thread-25] INFO  o.a.e.i.asyncexecutor.AcquireAsyncJobsDueRunnable - {} starting to acquire async jobs due
2023-04-25 10:36:07.542 [Thread-27] INFO  o.a.e.impl.asyncexecutor.ResetExpiredJobsRunnable - {} starting to reset expired jobs
2023-04-25 10:36:08.869 [main] WARN  o.s.cloud.openfeign.FeignClientFactoryBean - The provided URL is empty. Will try picking an instance via load-balancing.
2023-04-25 10:36:11.137 [main] INFO  org.reflections.Reflections - Reflections took 34 ms to scan 1 urls, producing 3 keys and 6 values 
2023-04-25 10:36:11.177 [main] INFO  org.reflections.Reflections - Reflections took 16 ms to scan 1 urls, producing 4 keys and 9 values 
2023-04-25 10:36:11.196 [main] INFO  org.reflections.Reflections - Reflections took 16 ms to scan 1 urls, producing 3 keys and 10 values 
2023-04-25 10:36:11.434 [main] INFO  org.reflections.Reflections - Reflections took 235 ms to scan 317 urls, producing 0 keys and 0 values 
2023-04-25 10:36:11.453 [main] INFO  org.reflections.Reflections - Reflections took 18 ms to scan 1 urls, producing 1 keys and 5 values 
2023-04-25 10:36:11.473 [main] INFO  org.reflections.Reflections - Reflections took 18 ms to scan 1 urls, producing 1 keys and 7 values 
2023-04-25 10:36:11.491 [main] INFO  org.reflections.Reflections - Reflections took 14 ms to scan 1 urls, producing 2 keys and 8 values 
2023-04-25 10:36:11.772 [main] INFO  org.reflections.Reflections - Reflections took 277 ms to scan 317 urls, producing 0 keys and 0 values 
2023-04-25 10:36:17.556 [main] INFO  o.s.b.actuate.endpoint.web.EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
2023-04-25 10:36:17.721 [main] INFO  com.ssjf.activiti.actest.config.XxlJobConfig - >>>>>>>>>>> xxl-job config init.
2023-04-25 10:36:17.894 [main] INFO  o.s.b.a.web.servlet.WelcomePageHandlerMapping - Adding welcome page template: index
2023-04-25 10:36:19.858 [main] WARN  o.s.c.l.c.LoadBalancerCacheAutoConfiguration$LoadBalancerCaffeineWarnLogger - Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2023-04-25 10:36:19.966 [main] INFO  com.xxl.job.core.executor.XxlJobExecutor - >>>>>>>>>>> xxl-job register jobhandler success, name:storeGetSignFlowDocUrlsHandler, jobHandler:com.xxl.job.core.handler.impl.MethodJobHandler@4734a551[class com.ssjf.activiti.actest.job.StoreJob#storeGetSignFlowDocUrlsHandler]
2023-04-25 10:36:19.967 [main] INFO  com.xxl.job.core.executor.XxlJobExecutor - >>>>>>>>>>> xxl-job register jobhandler success, name:getSignFlowDocUrlsHandler, jobHandler:com.xxl.job.core.handler.impl.MethodJobHandler@780ccdc9[class com.ssjf.activiti.actest.job.SubdistributorJob#getSignFlowDocUrlsHandler]
2023-04-25 10:36:20.019 [main] WARN  o.s.cloud.openfeign.FeignClientFactoryBean - The provided URL is empty. Will try picking an instance via load-balancing.
2023-04-25 10:36:20.166 [main] WARN  com.xxl.job.core.executor.XxlJobExecutor - >>>>>>>>>>> xxl-job accessToken is empty. To ensure system security, please set the accessToken.
2023-04-25 10:36:20.339 [main] INFO  org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8218"]
2023-04-25 10:36:20.356 [main] INFO  o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8218 (http) with context path ''
2023-04-25 10:36:20.374 [main] INFO  c.a.cloud.nacos.registry.NacosServiceRegistry - nacos registry, DEFAULT_GROUP ssjf49-actest 192.168.0.51:8218 register finished
2023-04-25 10:36:21.422 [Thread-69] INFO  com.xxl.job.core.server.EmbedServer - >>>>>>>>>>> xxl-job remoting server start success, nettype = class com.xxl.job.core.server.EmbedServer, port = 8096
2023-04-25 10:36:23.463 [main] INFO  com.ssjf.activiti.actest.ActestApplication - Started ActestApplication in 27.765 seconds (JVM running for 30.325)
2023-04-25 10:36:23.473 [main] INFO  c.ssjf.activiti.actest.config.FontsRegisterRunner - 字体加载开始
2023-04-25 10:36:23.812 [main] INFO  c.ssjf.activiti.actest.config.FontsRegisterRunner - 注册字体成功-fontName:微软雅黑
2023-04-25 10:36:23.812 [main] INFO  c.ssjf.activiti.actest.config.FontsRegisterRunner - 字体加载结束
2023-04-25 10:36:23.813 [main] INFO  c.ssjf.activiti.actest.config.FontsRegisterRunner - allFonts-allFonts: AcadEref,Adobe Devanagari,Agency FB,AIGDT,Algerian,AmdtSymbols,AMGDT,Arial,Arial Black,Arial Narrow,Arial Rounded MT Bold,Bahnschrift,BankGothic Lt BT,BankGothic Md BT,Baskerville Old Face,Bauhaus 93,Bell MT,Berlin Sans FB,Berlin Sans FB Demi,Bernard MT Condensed,Blackadder ITC,Bodoni MT,Bodoni MT Black,Bodoni MT Condensed,Bodoni MT Poster Compressed,Book Antiqua,Bookman Old Style,Bookshelf Symbol 7,Bradley Hand ITC,Britannic Bold,Broadway,Brush Script MT,Calibri,Calibri Light,Californian FB,Calisto MT,Cambria,Cambria Math,Candara,Candara Light,Castellar,Centaur,Century,Century Gothic,Century Schoolbook,Chiller,CityBlueprint,Colonna MT,Comic Sans MS,CommercialPi BT,CommercialScript BT,Complex,Consolas,Constantia,Cooper Black,Copperplate Gothic Bold,Copperplate Gothic Light,Corbel,Corbel Light,CountryBlueprint,Courier New,Curlz MT,DejaVu Math TeX Gyre,Dialog,DialogInput,Dutch801 Rm BT,Dutch801 XBd BT,Ebrima,Edwardian Script ITC,Elephant,Engravers MT,Eras Bold ITC,Eras Demi ITC,Eras Light ITC,Eras Medium ITC,EuroRoman,Felix Titling,Footlight MT Light,Forte,Franklin Gothic Book,Franklin Gothic Demi,Franklin Gothic Demi Cond,Franklin Gothic Heavy,Franklin Gothic Medium,Franklin Gothic Medium Cond,Freestyle Script,French Script MT,Gabriola,Gadugi,Garamond,GDT,Georgia,Gigi,Gill Sans MT,Gill Sans MT Condensed,Gill Sans MT Ext Condensed Bold,Gill Sans Ultra Bold,Gill Sans Ultra Bold Condensed,Gloucester MT Extra Condensed,GothicE,GothicG,GothicI,Goudy Old Style,Goudy Stout,GreekC,GreekS,Haettenschweiler,Harlow Solid Italic,Harrington,High Tower Text,HoloLens MDL2 Assets,Impact,Imprint MT Shadow,Informal Roman,Ink Free,ISOCP,ISOCP2,ISOCP3,ISOCPEUR,ISOCT,ISOCT2,ISOCT3,ISOCTEUR,Italic,ItalicC,ItalicT,Javanese Text,Jokerman,Juice ITC,Kristen ITC,Kunstler Script,Leelawadee UI,Leelawadee UI Semilight,Lucida Bright,Lucida Calligraphy,Lucida Console,Lucida Fax,Lucida Handwriting,Lucida Sans,Lucida Sans Typewriter,Lucida Sans Unicode,Magneto,Maiandra GD,Malgun Gothic,Malgun Gothic Semilight,Marlett,Matura MT Script Capitals,Microsoft Himalaya,Microsoft JhengHei,Microsoft JhengHei Light,Microsoft JhengHei UI,Microsoft JhengHei UI Light,Microsoft New Tai Lue,Microsoft PhagsPa,Microsoft Sans Serif,Microsoft Tai Le,Microsoft YaHei UI,Microsoft YaHei UI Light,Microsoft Yi Baiti,MingLiU-ExtB,MingLiU_HKSCS-ExtB,Mistral,Modern No. 20,Mongolian Baiti,Monospac821 BT,Monospaced,Monotxt,Monotype Corsiva,MS Gothic,MS Outlook,MS PGothic,MS Reference Sans Serif,MS Reference Specialty,MS UI Gothic,MT Extra,MV Boli,Myanmar Text,Niagara Engraved,Niagara Solid,Nirmala UI,Nirmala UI Semilight,OCR A Extended,Old English Text MT,Onyx,Palace Script MT,Palatino Linotype,PanRoman,Papyrus,Parchment,Perpetua,Perpetua Titling MT,Playbill,PMingLiU-ExtB,Poor Richard,Pristina,Proxy 1,Proxy 2,Proxy 3,Proxy 4,Proxy 5,Proxy 6,Proxy 7,Proxy 8,Proxy 9,Rage Italic,Ravie,Rockwell,Rockwell Condensed,Rockwell Extra Bold,RomanC,RomanD,RomanS,RomanT,Romantic,Sans Serif Collection,SansSerif,Script MT Bold,ScriptC,ScriptS,Segoe Fluent Icons,Segoe MDL2 Assets,Segoe Print,Segoe Script,Segoe UI,Segoe UI Black,Segoe UI Emoji,Segoe UI Historic,Segoe UI Light,Segoe UI Semibold,Segoe UI Semilight,Segoe UI Symbol,Segoe UI Variable,Serif,Showcard Gothic,Simplex,SimSun-ExtB,Sitka Text,Snap ITC,Stencil,Stylus BT,SuperFrench,Swis721 BdCnOul BT,Swis721 BdOul BT,Swis721 Blk BT,Swis721 BlkCn BT,Swis721 BlkEx BT,Swis721 BlkOul BT,Swis721 BT,Swis721 Cn BT,Swis721 Ex BT,Swis721 Lt BT,Swis721 LtCn BT,Swis721 LtEx BT,Syastro,Sylfaen,Symap,Symath,Symbol,Symeteo,Symusic,Tahoma,Technic,TechnicBold,TechnicLite,Tempus Sans ITC,Times New Roman,Trebuchet MS,Tw Cen MT,Tw Cen MT Condensed,Tw Cen MT Condensed Extra Bold,Txt,UniversalMath1 BT,Verdana,Viner Hand ITC,Vineta BT,Vivaldi,Vladimir Script,Webdings,Wide Latin,Wingdings,Wingdings 2,Wingdings 3,Yu Gothic,Yu Gothic Light,Yu Gothic Medium,Yu Gothic UI,Yu Gothic UI Light,Yu Gothic UI Semibold,Yu Gothic UI Semilight,ZWAdobeF,仿宋,华文中宋,华文仿宋,华文宋体,华文彩云,华文新魏,华文楷体,华文琥珀,华文细黑,华文行楷,华文隶书,宋体,幼圆,微软雅黑,微软雅黑 Light,新宋体,方正姚体,方正舒体,楷体,等线,等线 Light,隶书,黑体
2023-04-25 10:36:25.714 [RMI TCP Connection(3)-192.168.200.18] INFO  o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-04-25 10:36:25.714 [RMI TCP Connection(3)-192.168.200.18] INFO  org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
2023-04-25 10:36:25.716 [RMI TCP Connection(3)-192.168.200.18] INFO  org.springframework.web.servlet.DispatcherServlet - Completed initialization in 2 ms
2023-04-25 10:36:26.094 [boundedElastic-1] WARN  o.s.b.actuate.redis.RedisReactiveHealthIndicator - Redis health check failed
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1671)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1579)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1365)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1348)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedReactiveConnection(LettuceConnectionFactory.java:1099)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:511)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:103)
	at reactor.core.publisher.MonoSupplier.call(MonoSupplier.java:86)
	at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
	at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78)
	at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56)
	at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:330)
	at io.lettuce.core.RedisClient.connect(RedisClient.java:216)
	at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115)
	at java.util.Optional.orElseGet(Optional.java:267)
	at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1577)
	... 16 common frames omitted
Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:137)
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:110)
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
	at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
	at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:63)
	at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:746)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:681)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:598)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	... 1 common frames omitted

在配置文件application.yml中加上

# 禁止Actuator监控Redis连接
management:
  health:
    redis:
      enabled: false