1. Create a new maven module subproject microservicecloud-eureka-server
2. 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>com.atguigu.springcloud</groupId> <artifactId>microservicecloud</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>microservicecloud-config-eureka-client-7001</artifactId> <dependencies> <!-- SpringCloudConfig配置 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> <!-- 热部署插件 --> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> </dependencies> </project>
三 、 application.yml
server:
port: 7001
eureka:
instance:
hostname: localhost #eureka server instance name
client:
register-with-eureka: false #false means not to register myself in the
registry fetch-registry: false #false means that my end is the registry, my duty is to maintain the service instance, and I don't need to retrieve the service
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #Setting the address query service and registration service that interact with Eureka Server need to rely on this address (the address exposed by the service)
Fourth, the main program
package com.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class EurekaServer7001_application { public static void main(String[] args) { SpringApplication.run(EurekaServer7001_application.class, args); } }
5. Running results