资讯专栏INFORMATION COLUMN

Ignore the empty nacos configuration and get it ba

不知名网友 / 4690人阅读

摘要:被坑惨了客户端访问位置这段一定要看懂默认为的值也可以通过配置项来配置即为当前环境对应的。目前只支持和类型。应用实时更新启动用浏览器总结一定要先建项目,再根据项目建配置

被坑惨了

1.pom.xml

    4.0.0            org.springframework.boot        spring-boot-starter-parent        2.1.1.RELEASE                 com    test-3    0.0.1-SNAPSHOT    test-3    Demo project for Spring Boot            1.8                            org.springframework.boot            spring-boot-starter-web                            org.springframework.boot            spring-boot-starter-test            test                            org.springframework.cloud            spring-cloud-starter-alibaba-nacos-config            0.9.0.RELEASE            

2.yml

server:  port: 6666spring:  application:    name: config  cloud:    nacos:      config:        server-addr: localhost:8848//nacos客户端访问位置        file-extension: yml  profiles:    active: dev

 

这段一定要看懂    

 

${prefix}-${spring.profile.active}.${file-extension}

  • prefix默认为spring.application.name的值,也可以通过配置项spring.cloud.nacos.config.prefix`来配置

  • spring.profile.active即为当前环境对应的profile。注意:当spring.profile.active为空时,对应的连接符-也将不存在,dataId的拼接格式变成${prefix}.${file-extension}

  • file-extension为配置内容的数据格式,可以通过配置项为spring.cloud.nacos.config.file-extension来配置。目前只支持propertiesyaml类型。

3.应用controller

@RestController@RefreshScope//实时更新public class Configg {    @Value("${config.code}")    private String code;@GetMapping("/cong")    public String cong(){    return code;}}

4.启动

5.用浏览器    localhost:6666/cong

总结

一定要先建项目,再根据项目建nacos配置

 

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/125638.html

相关文章

  • Dubbo Spring Cloud 重塑微服务治理

    摘要:在服务治理方面,相较于而言,并不成熟。遗憾的是,往往被部分开发者片面地视作服务治理的框架,而非微服务基础设施。因此,建议开发人员将或者迁移为服务。因此,下一步需要将其配置服务远程。当服务提供方启动后,下一步实现一个服务消费方。 原文链接:Dubbo Spring Cloud 重塑微服务治理,来自于微信公众号:次灵均阁 摘要 在 Java 微服务生态中,Spring Cloud1 成为...

    wh469012917 评论0 收藏0
  • Wire Protocol of PostgreSQL Queries in a Nutshell

    摘要: I was working on a pull request to improve the performance of executemany() in asyncpg, who talks to the PostgreSQL server directly in its wire protocol (comparing to psycopg2 who uses libpq to...

    陆斌 评论0 收藏0
  • Wire Protocol of PostgreSQL Queries in a Nutshell

    摘要: I was working on a pull request to improve the performance of executemany() in asyncpg, who talks to the PostgreSQL server directly in its wire protocol (comparing to psycopg2 who uses libpq to...

    teren 评论0 收藏0
  • docker部署单机nacos

    摘要:部署拉取镜像创建文件夹创建工作目录创建日志目录创建配置文件创建配置文件对应参数说明模式模式地址是否支持服务器端口多网卡下的自定义服务器支持主节点主节点端口主节点数据库数据库用户名数据库密码从节点从节点端口数据库数量部署 Nacos1、拉取镜像docker pull nacos/nacos-server2、创建nacos文件夹创建naocs工作目录: mkdir /usr/data/nacos...

    Tecode 评论0 收藏0
  • PHP|标准配置之php.ini (2)

    摘要: ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; [CLI Server] ; Whether the CLI web server uses ANSI color coding in its terminal output. cli_server.color = On [Date] ; Defines th...

    tianren124 评论0 收藏0

发表评论

0条评论

不知名网友

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<