1:pom
1.1:父pom
<!--Spring cloud alibaba dependencies --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring.cloud.alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!-- nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>${nacos-version}</version> </dependency>
1.2:项目pom
<!-- spring-cloud-alibaba --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${alibaba-dependencies-version}</version> <type>pom</type> </dependency> <!-- nacos-discovery --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
2:yml
server: port: 9001 #服务端口号 spring: application: name: nacos-payment-provider # 也是注册到 nacos 服务的名称( 服务别名(使用服务别名去注册中心获取实际的RPC远程调用地址) ) cloud: nacos: discovery: server-addr: 127.0.0.1:8848
management: endpoints: web: exposure: include: '*'
3:注解
@EnableDiscoveryClient @SpringBootApplication public class Paytment9001 { public static void main(String[] args) { SpringApplication.run(Paytment9001.class); } }
分配端口:9001 9002 9003