学习Alibaba NACOS 初学者简易配置

本文档提供了一步一步的Alibaba NACOS配置教程,从下载NACOS到启动服务,再到访问控制台。接着,介绍了如何基于Java 1.8创建一个Maven工程,包括配置YML文件和启动微服务。对于学习Nacos的初学者,这篇简要笔记旨在提供帮助。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

学习Alibaba NACOS 初学者简易配置

1、官网下载NACOS
地址:https://github.com/alibaba/Nacos
在这里插入图片描述
2、进行解压,然后再该目录下运行cmd
在这里插入图片描述
3、启动nacos
在这里插入图片描述
4、访问
地址:http://localhost:8848/nacos
账号:nacos
密码:nacos
在这里插入图片描述
5、成功页面
在这里插入图片描述
6、创建maven工程
基于java1.8版本:
cloudalibaba-provider-payment9001

(1)POM文件

<dependencies>
        <!--spring cloud Alibaba-->
	      <dependency>
	        <groupId>com.alibaba.cloud</groupId>
	        <artifactId>spring-cloud-alibaba-dependencies</artifactId>
	        <version>2.1.0.RELEASE</version>
	        <type>pom</type>
	        <scope>import</scope>
	      </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!-- springboot整合Web组件 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

(2)配置YML文件

server:
  port: 9001

spring:
  application:
    name: cloudalibaba-provider-payment9001
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848

management:
  endpoints:
    web:
      exposure:
        include: "* "

(3)主启动类

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableDiscoveryClient
public class CloudAlibabaProviderMain9001 {

    public static void main(String[] args) {
        SpringApplication.run(CloudAlibabaProviderMain9001.class,args);
    }
}

(4)启动9001端口微服务
在这里插入图片描述

这里刚好在学习Alibaba nacos,简略的做个笔记,希望能帮助有需要的小伙伴,如有问题,互相探讨。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值