整合 nacos註冊中心配置使用

FH-Admin發表於2021-11-23

pom

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <shiro.version>1.7.1</shiro.version><!-- fhadmin.cn -->
        <spring-cloud.version>2020.0.3</spring-cloud.version>
        <spring-cloud-Alibaba.version>2021.1</spring-cloud-Alibaba.version>
        <maven-jar-plugin.version>3.0.0</maven-jar-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-Alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>        
        </dependencies>
    </dependencyManagement>

<dependencies>
         <!-- nacos註冊中心 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId><!-- fhadmin.cn -->
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
</dependencies>

application.properties

#nacos指向註冊中心 fhadmin.cn
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#nacos訪問地址的使用者名稱
spring.cloud.nacos.discovery.username=nacos
#nacos訪問地址的密碼
spring.cloud.nacos.discovery.password=nacos
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章