开发者社区> 问答> 正文

nacos读错配置文件

这个是我的bootstrap.yml文件配置

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@

这个是报错文件

group[DEFAULT_GROUP] 2022-02-08 10:51:15.500 [main] INFO  com.alibaba.nacos.client.config.utils.JvmUtil:49 - isMultiInstance:false 2022-02-08 10:51:15.566 [main] INFO  o.s.c.b.c.PropertySourceBootstrapConfiguration:112 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-test1-prod.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-test1.yaml(指定的配置文件),DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-test1,DEFAULT_GROUP'}] 2022-02-08 10:51:15.870 [main] INFO  com.shenyue.collectionpro.CollectionProApplication:655 - The following profiles are active: prod 2022-02-08 10:51:20.068 [main] INFO  o.springframework.cloud.context.scope.GenericScope:295 - BeanFactory id=1ff5477b-c33c-3eb5-83ee-fef1bf3e88e5 2022-02-08 10:51:22.824 [main] INFO  o.s.boot.web.embedded.tomcat.TomcatWebServer:108 - Tomcat initialized with port(s): 8082 (http) 2022-02-08 10:51:23.146 [main] INFO  org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-8082"] 2022-02-08 10:51:23.147 [main] INFO  org.apache.catalina.core.StandardService:173 - Starting service [Tomcat] 2022-02-08 10:51:23.147 [main] INFO  org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.39] 2022-02-08 10:51:23.952 [main] INFO  o.a.c.c.C.[Tomcat].[localhost].[/collection-pro]:173 - Initializing Spring embedded WebApplicationContext 2022-02-08 10:51:23.952 [main] INFO  o.s.b.w.s.c.ServletWebServerApplicationContext:285 - Root WebApplicationContext: initialization completed in 7925 ms 2022-02-08 10:51:25.452 [main] WARN  com.netflix.config.sources.URLConfigurationSource:121 - No URLs will be polled as dynamic configuration sources. 2022-02-08 10:51:25.453 [main] INFO  com.netflix.config.sources.URLConfigurationSource:122 - To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2022-02-08 10:51:25.539 [main] WARN  com.netflix.config.sources.URLConfigurationSource:121 - No URLs will be polled as dynamic configuration sources. 2022-02-08 10:51:25.539 [main] INFO  com.netflix.config.sources.URLConfigurationSource:122 - To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2022-02-08 10:51:26.046 [main] INFO  o.s.scheduling.concurrent.ThreadPoolTaskExecutor:181 - Initializing ExecutorService 'applicationTaskExecutor' 2022-02-08 10:51:26.676 [main] INFO  o.s.scheduling.concurrent.ThreadPoolTaskScheduler:181 - Initializing ExecutorService 'taskScheduler' 2022-02-08 10:51:26.871 [main] INFO  org.apache.coyote.http11.Http11NioProtocol:173 - Starting ProtocolHandler ["http-nio-8082"] 2022-02-08 10:51:26.962 [main] INFO  o.s.boot.web.embedded.tomcat.TomcatWebServer:220 - Tomcat started on port(s): 8082 (http) with context path '/collection-pro' 2022-02-08 10:51:26.969 [main] WARN  com.shenyue.collectionpro.mdb.convert.DBConvert:152 -  2022-02-08 10:51:26.980 [main] INFO  com.alibaba.nacos.client.naming:64 - initializer namespace from System Property :null 2022-02-08 10:51:26.982 [main] INFO  com.alibaba.nacos.client.naming:73 - initializer namespace from System Environment :null 2022-02-08 10:51:26.983 [main] INFO  com.alibaba.nacos.client.naming:83 - initializer namespace from System Property :null 2022-02-08 10:51:27.137 [main] INFO  com.alibaba.nacos.client.naming:81 - [BEAT] adding beat: BeatInfo{port=8082, ip='192.168.1.88', weight=1.0, serviceName='DEFAULT_GROUP@@lingbozhnaoyang', cluster='DEFAULT', metadata={preserved.register.source=SPRING_CLOUD}, scheduled=false, period=5000, stopped=false} to beat map. 2022-02-08 10:51:27.138 [main] INFO  com.alibaba.nacos.client.naming:223 - [REGISTER-SERVICE] material registering service DEFAULT_GROUP@@lingbozhnaoyang with instance: Instance{instanceId='null', ip='192.168.1.88', port=8082, weight=1.0, healthy=true, enabled=true, ephemeral=true, clusterName='DEFAULT', serviceName='null', metadata={preserved.register.source=SPRING_CLOUD}} 2022-02-08 10:51:27.149 [main] INFO  c.a.cloud.nacos.registry.NacosServiceRegistry:71 - nacos registry, DEFAULT_GROUP lingbozhnaoyang 192.168.1.88:8082 register finished 2022-02-08 10:51:27.248 [main] INFO  com.shenyue.collectionpro.CollectionProApplication:61 - Started CollectionProApplication in 30.075 seconds (JVM running for 58.115) 2022-02-08 10:51:27.257 [main] WARN  com.shenyue.collectionpro.CollectionProApplication:26  : 《配置文件名称:test2》 

 我是用windows注册成服务的下面是我指定配置的文件

       collection-pro     注册的服务名     This service is a service created from a minimal configuration        C:\java\jre1.8.0_191\bin\java      -Xmx1024m -Dfile.encoding=utf-8 -jar collection-pro.jar <!--   MIT License

    collection-pro     注册的服务名     This service is a service created from a minimal configuration        C:\java\jre1.8.0_191\bin\java      -Xmx1024m -Dfile.encoding=utf-8 -jar collection-pro.jar --spring.application.name="心跳名称指定" --spring.cloud.nacos.config.prefix="指定的配置文件"

"

各位大佬请指教,如果需要补充欢迎评论。

万分感谢

展开
收起
eh6myni42yv4y 2022-02-16 17:20:53 1714 0
1 条回答
写回答
取消 提交回答
  • 需要引入依赖:在spring cloud 2020版本需要使用bootstrap.yaml作为配置文件需要手动引入依赖

    org.springframework.cloud spring-cloud-starter-bootstrap 3.0.2

    2022-05-23 12:47:43
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Nacos架构&原理 立即下载
workshop专场-微服务专场-开发者动手实践营-微服务-使用Nacos进行服务的动态发现和流量调度 立即下载
Nacos 启航,发布第一个版本, 云原生时代助力用户微服务平台建设 立即下载