支付微服务8001入驻EurekaServer

本文详细介绍了如何将支付微服务8001整合到EurekaServer中,包括修改pom.xml添加Eureka客户端依赖,配置服务启动端口、数据源、Eureka服务地址,以及在主启动类启用EurekaClient注解。通过这些步骤,成功实现了支付微服务在EurekaServer的注册与发现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

支付微服务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就完成了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值