支付微服务8001入驻EurekaServer
一、修改支付微服务8001的pom.xml文件
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>3.0.3</version>
</dependency>
二、修改支付微服务8001的配置文件
server:
port: 8001
spring:
application:
name: cloud-payment-serice
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/SpringCloudStudydb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
eureka:
client:
#表示是否将自己注册进EurekaServer默认为true .
register-with-eureka: true
#是否从EurekaServer抓取已有的注册信息,默认为true。单节点无所谓,集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://localhost:7001/eureka
mybatis:
# 指定mapper.xml文件存放的路径
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.junfu.springcloud.entities #所有Entity别名类所在包
三、修改支付微服务8001主启动类
package com.junfu.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class PaymentMain8081 {
public static void main(String[] args) {
SpringApplication.run(PaymentMain8081.class,args);
}
}
四、测试
启动cloud-provider-payment8001和cloud-eureka-server7001,然后刷新http://localhost:7001/,如果成功了,就会出现以下效果:
至此支付微服务8001入驻EurekaServer就完成了。