Eureka Registry
1. Create a new registry project; import the eureka-service package into the project.
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
2. Create a .yaml file for the project, because eureka is automatically registered by default, so it needs to be set to cancel the default registration. And set the port number
server:
port: 8761
eureka:
client:
register-with-eureka: false #由于Eureka项目是注册中心所以,不需要进行注册,将register-with-eureka 设置成 false ; fetch-registry 设置成 false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka/
Two problems were encountered when creating the Erueka project:
- Use the Eureka-client package in the registry. The project will not prompt an error, but it will report a 404 when accessing the Eureka registry. The error only needs to be changed to eureka-server and registered in the application
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication{
}
- The operation was successful, but Unregistering application xxx with eureka with status DOWN followed.
The reason is that I did not add the web library after adding the Spring web library and there was no such error.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>