P2 spring-cloud+layui搭建后台管理系统-eureka注册中心

父工程搭建完毕后,接下来要搭建注册中心,所有的服务都要通过注册中心注册发现,才能进行调用。
new ->maven Project ->create a simple project 父工程选择之前建立的parent工程
在这里插入图片描述
修改pom.xml文件

<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>
  <parent>
    <groupId>org.joey</groupId>
    <artifactId>baymin-cloud-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>baymin-cloud-eureka</artifactId>
  <name>baymin-cloud-eureka</name>
  <description>服务注册中心</description>
  <!--声明编码版本,和java版本  -->
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
  </properties>
  <build>
    <plugins>
    <!--springboot项目maven打包插件  -->
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <!--指定项目的main方法  -->
        <configuration>
          <mainClass>org.joey.baymin.BayminEurekaApplication</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <!--依赖库  -->
  <repositories>
    <repository>
      <id>aliyun</id>
      <name>aliyun</name>
      <url>https://maven.aliyun.com/repository/public</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
   <dependencies>
   <!--注册中心服务端 -->
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
    <!--注册中心客户端 -->
    <dependency>
      <groupId>de.codecentric</groupId>
      <artifactId>spring-boot-admin-starter-client</artifactId>
      <version>2.0.6</version>
    </dependency>
  </dependencies>
</project>

创建springboot启动类
在这里插入图片描述

@EnableEurekaServer
@SpringBootApplication
public class BayminEurekaApplication {
//服务中心
	public static void main(String[] args) {
		 SpringApplication.run(BayminEurekaApplication.class, args);
	}
}

添加
@EnableEurekaServer
@SpringBootApplication
两个注解,表示这是springboot类型的注册中心
添加application.properties配置文件

spring.profiles.active=dev
spring.application.name=plisp-eureka-server
server.port=8761
eureka.instance.hostname=localhost
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

# 关闭自我保护模式(缺省为打开)
eureka.server.enable-self-preservation=false
# 续期时间,即扫描失效服务的间隔时间(缺省为60*1000ms)
eureka.server.eviction-interval-timer-in-ms=5000

spring.boot.admin.client.url=http://192.168.0.6:8760
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.boot.admin.client.instance.prefer-ip=true

dev里面

spring.boot.admin.client.url=http://127.0.0.1:8760

启动注册中心服务类
输入地址 127.0.0.1:8761 进入注册中心服务端
在这里插入图片描述
如此 注册中心搭建完毕。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值