UTF-8
UTF-8
1.8
Hoxton.SR8
2.2.0.RELEASE
org.springframework.boot
spring-boot-starter-parent
2.2.13.RELEASE
com.alibaba.cloud
spring-cloud-alibaba-dependencies
${alibaba.version}
pom
import
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
junit
junit
4.12
dev
dev
true
test
test
prod
prod
2、在用户服务(user-server-biz)pom引入依赖
3、在用户服务(user-server-biz)创建主启动类src/main/resources true org.springframework.boot spring-boot-starter-web com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery
@SpringBootApplication
@EnableDiscoveryClient //开启注册发现
public class UserServerApplication {
public static void main(String[] args) {
SpringApplication.run(UserServerApplication.class);
}
}
4、配置yml文件
server:
port: 8001
spring:
application:
name: @artifactId@
cloud:
nacos:
discovery:
#nacos的地址
server-addr: ${NACOS_HOST:ruyi-register}:${NACOS_PORT:8848}
#命名空间
namespace: c6835035-f1d6-48f6-a802-96e72114cbf9
- 我这里配置了host,所以yml里面用的域名ruyi-register,不想配置就直接写注册中心的ip地址
看到了用户服务,成功!



