人生就象弈棋, 一步失误, 全盘皆输,这是令人悲哀之事;而且人生还不如弈棋,不可能再来一局,也不能悔棋。—— 弗洛伊德
下载
找到zip
下载解压即可
进入bin
目录
1 2
| # 单机启动 startup.cmd -m standalone
|
然后我们可以引入java
的SDK
使用maven
的GAV
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <dependencies> <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> <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
1 2 3 4 5 6 7
| spring: cloud: nacos: config: server-addr: 127.0.0.1:8848 application: name: ruben-provider
|
启动项目可以看到日志输出
然后访问nacos
控制台
输入默认用户名nacos
密码nacos
也能看到我们的nacos
单机节点正常运行
在主启动类中配置@EnableDiscoveryClient
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| 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); }
}
|
启动后可以看到服务已经注册成功