tufei1846 2022-02-11 14:55 采纳率: 33.3%
浏览 174
已结题

客户端naocs过一段时间配置会读取不到

问题遇到的现象和发生背景

我把项目注册了成一个服务到windows上一开始能读取到,过一段时间会出现读取不到或者读取到错误的配置,可能是因为断网或者电脑重启。

问题相关代码

这是我的xml文件配置

<service>
  
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>collection-pro</id>
  <!-- Display name of the service -->
  <name>Java 程序</name>
  <!-- Service description -->
  <description>This service is a service created from a minimal configuration</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>C:\java\jre1.8.0_191\bin\java</executable>
  
  <arguments>-Xmx1024m -Dfile.encoding=utf-8 -jar collection-pro.jar --spring.application.name="***" --spring.cloud.nacos.config.prefix="***"</arguments>

</service>

这是我bootstrap配置

spring:
  profiles:
    active: @profile.name@
  cloud:
    nacos:
      config:
        # Nacos 认证用户
        username: @config.username@
        # Nacos 认证密码
        password: @config.password@
        # 命名空间 常用场景之一是不同环境的配置的区分隔离,例如开发测试环境和生产环境的资源(如配置、服务)隔离等
        namespace: @config.namespace@
        # 配置中心地址
        server-addr: @config.server-addr@
        # 配置对应的分组
        group: @config.group@
        # 配置文件后缀
        file-extension: yaml
    #    prefix: '***'
        refresh-enabled: true
      discovery:
        namespace: @config.namespace@
        server-addr: @config.server-addr@
        watch:
          enabled: false
        username: @config.username@
        password: @config.password@

这是我配置文件的命名方式

***-prod.yaml

version

<spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version>

运行结果及报错内容

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

2022-01-05 13:30:56.087 [main] [31mWARN [0;39m [36mc.a.cloud.nacos.client.NacosPropertySourceBuilder:87[0;39m - Ignore the empty nacos configuration and get it based on dataId[***] & group[DEFAULT_GROUP]
2022-01-05 13:30:56.105 [main] [31mWARN [0;39m [36mc.a.cloud.nacos.client.NacosPropertySourceBuilder:87[0;39m - Ignore the empty nacos configuration and get it based on dataId[***.yaml] & group[DEFAULT_GROUP]
2022-01-05 13:30:56.118 [main] [31mWARN [0;39m [36mc.a.cloud.nacos.client.NacosPropertySourceBuilder:87[0;39m - Ignore the empty nacos configuration and get it based on dataId[***-prod.yaml] & group[DEFAULT_GROUP]
2022-01-05 13:30:56.120 [main] [34mINFO [0;39m [36mo.s.c.b.c.PropertySourceBootstrapConfiguration:112[0;39m - Located property source: [BootstrapPropertySource {name='bootstrapProperties-***-prod.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-***.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-***,DEFAULT_GROUP'}]
2022-01-05 13:30:56.244 [main] [34mINFO [0;39m [36mcom.shenyue.collectionpro.CollectionProApplication:655[0;39m - The following profiles are active: prod
2022-01-05 13:30:58.754 [main] [34mINFO [0;39m [36mo.springframework.cloud.context.scope.GenericScope:295[0;39m - BeanFactory id=1ff5477b-c33c-3eb5-83ee-fef1bf3e88e5
2022-01-05 13:30:59.657 [main] [34mINFO [0;39m [36mo.s.boot.web.embedded.tomcat.TomcatWebServer:108[0;39m - Tomcat initialized with port(s): 8082 (http)
2022-01-05 13:30:59.711 [main] [34mINFO [0;39m [36morg.apache.coyote.http11.Http11NioProtocol:173[0;39m - Initializing ProtocolHandler ["http-nio-8082"]
2022-01-05 13:30:59.713 [main] [34mINFO [0;39m [36morg.apache.catalina.core.StandardService:173[0;39m - Starting service [Tomcat]
2022-01-05 13:30:59.714 [main] [34mINFO [0;39m [36morg.apache.catalina.core.StandardEngine:173[0;39m - Starting Servlet engine: [Apache Tomcat/9.0.39]
2022-01-05 13:31:00.048 [main] [34mINFO [0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/collection-pro]:173[0;39m - Initializing Spring embedded WebApplicationContext
2022-01-05 13:31:00.055 [main] [34mINFO [0;39m [36mo.s.b.w.s.c.ServletWebServerApplicationContext:285[0;39m - Root WebApplicationContext: initialization completed in 3729 ms
2022-01-05 13:31:00.939 [main] [31mWARN [0;39m [36mcom.netflix.config.sources.URLConfigurationSource:121[0;39m - No URLs will be polled as dynamic configuration sources.
2022-01-05 13:31:00.941 [main] [34mINFO [0;39m [36mcom.netflix.config.sources.URLConfigurationSource:122[0;39m - To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2022-01-05 13:31:00.961 [main] [31mWARN [0;39m [36mcom.netflix.config.sources.URLConfigurationSource:121[0;39m - No URLs will be polled as dynamic configuration sources.
2022-01-05 13:31:00.961 [main] [34mINFO [0;39m [36mcom.netflix.config.sources.URLConfigurationSource:122[0;39m - To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2022-01-05 13:31:01.549 [main] [34mINFO [0;39m [36mo.s.scheduling.concurrent.ThreadPoolTaskExecutor:181[0;39m - Initializing ExecutorService 'applicationTaskExecutor'
2022-01-05 13:31:02.486 [main] [34mINFO [0;39m [36mo.s.scheduling.concurrent.ThreadPoolTaskScheduler:181[0;39m - Initializing ExecutorService 'taskScheduler'
2022-01-05 13:31:02.892 [main] [34mINFO [0;39m [36morg.apache.coyote.http11.Http11NioProtocol:173[0;39m - Starting ProtocolHandler ["http-nio-8082"]
2022-01-05 13:31:03.025 [main] [34mINFO [0;39m [36mo.s.boot.web.embedded.tomcat.TomcatWebServer:220[0;39m - Tomcat started on port(s): 8082 (http) with context path '/collection-pro'
2022-01-05 13:31:03.104 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:64[0;39m - initializer namespace from System Property :null
2022-01-05 13:31:03.106 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:73[0;39m - initializer namespace from System Environment :null
2022-01-05 13:31:03.109 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:83[0;39m - initializer namespace from System Property :null
2022-01-05 13:31:03.323 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:81[0;39m - [BEAT] adding beat: BeatInfo{port=8082, ip='192.168.1.127', weight=1.0, serviceName='DEFAULT_GROUP@@chengxishangjian', cluster='DEFAULT', metadata={preserved.register.source=SPRING_CLOUD}, scheduled=false, period=5000, stopped=false} to beat map.
2022-01-05 13:31:03.331 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:223[0;39m - [REGISTER-SERVICE] material registering service DEFAULT_GROUP@@chengxishangjian with instance: Instance{instanceId='null', ip='192.168.1.127', port=8082, weight=1.0, healthy=true, enabled=true, ephemeral=true, clusterName='DEFAULT', serviceName='null', metadata={preserved.register.source=SPRING_CLOUD}}
2022-01-05 13:31:03.351 [main] [34mINFO [0;39m [36mc.a.cloud.nacos.registry.NacosServiceRegistry:71[0;39m - nacos registry, DEFAULT_GROUP chengxishangjian 192.168.1.127:8082 register finished
2022-01-05 13:31:03.427 [main] [31mWARN [0;39m [36mo.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext:559[0;39m - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.fixedfield': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'fixedfield.bone1Plan' in value "${fixedfield.bone1Plan}"
2022-01-05 13:31:03.431 [main] [34mINFO [0;39m [36mo.s.scheduling.concurrent.ThreadPoolTaskScheduler:218[0;39m - Shutting down ExecutorService 'taskScheduler'
2022-01-05 13:31:03.438 [main] [34mINFO [0;39m [36mc.a.cloud.nacos.registry.NacosServiceRegistry:86[0;39m - De-registering from Nacos Server now...
2022-01-05 13:31:03.439 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:101[0;39m - [BEAT] removing beat: DEFAULT_GROUP@@chengxishangjian:192.168.1.127:8082 from beat map.
2022-01-05 13:31:03.440 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:253[0;39m - [DEREGISTER-SERVICE] material deregistering service DEFAULT_GROUP@@chengxishangjian with instance: Instance{instanceId='null', ip='192.168.1.127', port=8082, weight=1.0, healthy=true, enabled=true, ephemeral=true, clusterName='DEFAULT', serviceName='null', metadata={}}
2022-01-05 13:31:03.466 [main] [34mINFO [0;39m [36mc.a.cloud.nacos.registry.NacosServiceRegistry:106[0;39m - De-registration finished.
2022-01-05 13:31:03.467 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:147[0;39m - com.alibaba.nacos.client.naming.beat.BeatReactor do shutdown begin
2022-01-05 13:31:06.472 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:149[0;39m - com.alibaba.nacos.client.naming.beat.BeatReactor do shutdown stop
2022-01-05 13:31:06.473 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:149[0;39m - com.alibaba.nacos.client.naming.core.EventDispatcher do shutdown begin
2022-01-05 13:31:09.476 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:152[0;39m - com.alibaba.nacos.client.naming.core.EventDispatcher do shutdown stop
2022-01-05 13:31:09.482 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:370[0;39m - com.alibaba.nacos.client.naming.core.HostReactor do shutdown begin
2022-01-05 13:31:09.484 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:118[0;39m - com.alibaba.nacos.client.naming.core.PushReceiver do shutdown begin
2022-01-05 13:31:12.488 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:122[0;39m - com.alibaba.nacos.client.naming.core.PushReceiver do shutdown stop
2022-01-05 13:31:12.491 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:132[0;39m - com.alibaba.nacos.client.naming.backups.FailoverReactor do shutdown begin
2022-01-05 13:31:12.492 [com.alibaba.nacos.naming.push.receiver] [1;31mERROR[0;39m [36mcom.alibaba.nacos.client.naming:110[0;39m - [NA] error while receiving push data
java.net.SocketException: socket closed
    at java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
    at java.net.DualStackPlainDatagramSocketImpl.receive0(Unknown Source)
    at java.net.AbstractPlainDatagramSocketImpl.receive(Unknown Source)
    at java.net.DatagramSocket.receive(Unknown Source)
    at com.alibaba.nacos.client.naming.core.PushReceiver.run(PushReceiver.java:83)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
2022-01-05 13:31:13.313 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:134[0;39m - com.alibaba.nacos.client.naming.backups.FailoverReactor do shutdown stop
2022-01-05 13:31:13.314 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:374[0;39m - com.alibaba.nacos.client.naming.core.HostReactor do shutdown stop
2022-01-05 13:31:13.315 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:715[0;39m - com.alibaba.nacos.client.naming.net.NamingProxy do shutdown begin
2022-01-05 13:31:13.317 [main] [31mWARN [0;39m [36mcom.alibaba.nacos.client.naming:72[0;39m - [NamingHttpClientManager] Start destroying NacosRestTemplate
2022-01-05 13:31:13.317 [main] [31mWARN [0;39m [36mcom.alibaba.nacos.client.naming:79[0;39m - [NamingHttpClientManager] Destruction of the end
2022-01-05 13:31:13.318 [main] [34mINFO [0;39m [36mcom.alibaba.nacos.client.naming:718[0;39m - com.alibaba.nacos.client.naming.net.NamingProxy do shutdown stop
2022-01-05 13:31:13.320 [main] [31mWARN [0;39m [36mo.s.beans.factory.support.DisposableBeanAdapter:349[0;39m - Destroy method 'close' on bean with name 'nacosServiceRegistry' threw an exception: java.lang.NullPointerException
2022-01-05 13:31:13.320 [main] [34mINFO [0;39m [36mo.s.scheduling.concurrent.ThreadPoolTaskExecutor:218[0;39m - Shutting down ExecutorService 'applicationTaskExecutor'
2022-01-05 13:31:13.338 [main] [34mINFO [0;39m [36morg.apache.coyote.http11.Http11NioProtocol:173[0;39m - Pausing ProtocolHandler ["http-nio-8082"]
2022-01-05 13:31:13.373 [main] [34mINFO [0;39m [36morg.apache.catalina.core.StandardService:173[0;39m - Stopping service [Tomcat]
2022-01-05 13:31:13.546 [main] [34mINFO [0;39m [36morg.apache.coyote.http11.Http11NioProtocol:173[0;39m - Stopping ProtocolHandler ["http-nio-8082"]
2022-01-05 13:31:13.571 [main] [34mINFO [0;39m [36morg.apache.coyote.http11.Http11NioProtocol:173[0;39m - Destroying ProtocolHandler ["http-nio-8082"]
2022-01-05 13:31:13.580 [main] [34mINFO [0;39m [36mo.s.b.a.l.ConditionEvaluationReportLoggingListener:136[0;39m - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-01-05 13:31:13.583 [main] [1;31mERROR[0;39m [36morg.springframework.boot.SpringApplication:837[0;39m - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.fixedfield': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'fixedfield.bone1Plan' in value "${fixedfield.bone1Plan}"
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:363)
    at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:389)
    at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:186)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109)
    at org.springframework.cloud.context.scope.refresh.RefreshScope.eagerlyInitialize(RefreshScope.java:127)
    at org.springframework.cloud.context.scope.refresh.RefreshScope.start(RefreshScope.java:118)
    at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:112)
    at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:66)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
    at com.shenyue.collectionpro.CollectionProApplication.main(CollectionProApplication.java:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'fixedfield.bone1Plan' in value "${fixedfield.bone1Plan}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239)
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:918)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1248)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
    ... 36 common frames omitted
  • 写回答

2条回答 默认 最新

  • tufei1846 2022-02-11 15:15
    关注

    重新发布一下配置就又能读到了不知道为什么

    评论

报告相同问题?

问题事件

  • 系统已结题 2月19日
  • 修改了问题 2月11日
  • 创建了问题 2月11日

悬赏问题

  • ¥15 Windows下部署Asmjit
  • ¥15 请问双层规划模型的上下层目标函数不一致,是如何保证迭代收敛性的
  • ¥15 微信小程序 前端页面内容搜索
  • ¥15 cpu是如何判断当前指令已经执行完毕,然后去执行下条指令的
  • ¥15 安装visual studio2022时visualstudiosetup启动不了,闪退。问题代号0x0和0x1389
  • ¥30 java spring boot2.5.3版本websocket连不上
  • ¥15 angular js调外部链接查看pdf
  • ¥15 openFOAM DPMFoam
  • ¥15 将查询到的值,赋值到table指定行中
  • ¥50 docker容器内部启动shell脚本多命令