producers
Introducing dependencies:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
Copy the code
Yaml configuration:
Spring: nacos: Discovery: server-addr: 127.0.0.1:8848Copy the code
Start the class:
@EnableDiscoveryClient
@EnableFeignClients
@SpringBootApplication
public XXApplication(){
}
Copy the code
Business controller
omit
consumers
Introducing dependencies:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
Copy the code
Yaml configuration:
Spring: nacos: Discovery: server-addr: 127.0.0.1:8848Copy the code
Feign call:
@feignClients (value=" nacOS ") public interface ServiceAgent{... }Copy the code
A business call
@AutoWired
Start the class:
@EnableDiscoveryClient
@EnableFeignClients
@SpringBootApplication
public XXApplication(){
}
Copy the code