一 需求
将子系统 service_obj 和 service_cmn 注册到 Nacos 中。
二 步骤
1 在 service 模块pom文件引入依赖
<!-- 服务注册 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
2 在 service_obj 和 service_cmn 的配置文件添加 nacos 服务地址
# nacos 服务地址
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
3 在 service_obj 和 service_cmn 的启动类添加注解
@SpringBootApplication
@ComponentScan(basePackages = "com.baiyee")
@EnableDiscoveryClient
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}
@SpringBootApplication
@ComponentScan(basePackages = {"com.baiyee"})
@EnableDiscoveryClient
public class Ser