zoukankan      html  css  js  c++  java
  • Java实现-SpringBoot集成nocas实现日志集中管理

    1在SpringBoot项目pom.xml中添加依赖
    依赖注意版本 https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
    由于我的spring-boot-starter-parent版本为2.1.2.RELEASE,所以使用的是spring-cloud-alibaba-dependencies的版本为2.1.1.RELEASE

    <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.alibaba.cloud</groupId>
                    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                    <version>2.1.1.RELEASE</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
            </dependency>
        </dependencies>
    

     2在SpringBoot项目resources目录下中添加bootstrap.yaml

    spring:
      application:
          name: 与nocas服务器上对应的配置文件Data Id相同
      cloud:
          nacos:
            config:
              server-addr: nocas服务器地址:端口
              namespace: 命名空间ID(填入第三步自动生成的命名空间ID)
              file-extension: yaml
    

     3在nocas服务器上新建命名空间

     4在nacos上新建配置文件

     

    在原配置文件基础上加入以下配置

    spring:
      cloud:
          nacos:
            discovery:
              server-addr: nocas服务地址:端口
              namespace: 命名空间ID
    

     最后发布

    5将SpringBoot下的配置文件删除或将里面的配置项注释,启动,实例数会变为1 

  • 相关阅读:
    关于SQL Server将一列的多行内容拼接成一行的问题讨论
    Win7 disk.sys无法加载的问题
    mvel2.0语法指南
    让网页不被缓存的解决办法
    让html页面不缓存js的实现方法
    mysql中间件研究(tddl atlas cobar sharding-jdbc)
    jdk环境变量设置理解
    the import cannot be resolved
    Oracle解除表锁定问题
    windows系统中软件开发常用的软件
  • 原文地址:https://www.cnblogs.com/serena25/p/12618811.html
Copyright © 2011-2022 走看看