Provider项目

Provider项目

生产者用来提供服务

新建maven项目,引入spring boot的基本jar包

spring-boot-starter-parent:springboot parent模块
spring-boot-starter-web:spring boot web模块(这个包不引入服务将无法注册)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cloud.config</groupId>
    <artifactId>config</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>
        <!--spring boot web模块-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>



</project>

引入相关的jar包

eureka的客户端

  <!--eureka client-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

application配置文件

server:
  port: 9998
eureka:
  instance:
    hostname: 127.0.0.1
    lease-expiration-duration-in-seconds: 30
    lease-renewal-interval-in-seconds: 10
  client:
    service-url:
      defaultZone: http://${eureka.instance.hostname}:9999/eureka/
spring:
  application:
    name: eureka-user-manager     #注册的用户名
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/uc?useUnicode=true&characterEncoding=utf-8
    username: root
    password: root

编写启动类

@EnableEurekaClient:eureka的一个客户端

/**
 * @author :mmzs
 * @date :Created in 2020/1/3 18:05
 * @description:用户管理系统启动类
 * Provider项目 生产者
 * @modified By:
 * @version: 1$
 */
@SpringBootApplication
@EnableEurekaClient
public class UserManagerApplication {
    public static void main(String[] args) {
        SpringApplication.run(UserManagerApplication.class);
    }
}

踩过的坑

Cannot execute request on any known server
解决方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值