人生就象弈棋, 一步失误, 全盘皆输,这是令人悲哀之事;而且人生还不如弈棋,不可能再来一局,也不能悔棋。—— 弗洛伊德
找到zip
下载解压即可
进入bin
目录
# 单机启动
startup.cmd -m standalone
然后我们可以引入java
的SDK
使用maven
的GAV
<dependencies>
<!-- alibaba cloud -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
然后是bootstrap.yml
spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
application:
name: ruben-provider
启动项目可以看到日志输出
然后访问nacos
控制台
输入默认用户名nacos
密码nacos
也能看到我们的nacos
单机节点正常运行
在主启动类中配置@EnableDiscoveryClient
package com.ruben;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@EnableDiscoveryClient
@SpringBootApplication
@MapperScan({"com.ruben.dao.xml"})
public class SimpleSpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SimpleSpringbootApplication.class, args);
}
}
启动后可以看到服务已经注册成功