Home  >  Article  >  Java  >  Spring Cloud application eureka use

Spring Cloud application eureka use

无忌哥哥
无忌哥哥Original
2018-07-23 10:10:232400browse

The properties file on the server side is:

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

Start the server and visit localhost:8080 to see the server page.

The properties file on the client side is:

server.port=8081
spring.application.name=user_service_provider
eureka.client.serviceUrl.defaultZone=http://localhost:8080/eureka

Note: Even if the link http://localhost:8080/eureka does not exist when accessed with a browser, it must be written like this. Initially, it is :

eureka.client.serviceUrl.defaultZone=http://localhost:8080

You cannot register to the eureka server in this way.

Through the above configuration, the service provider can register to the eureka server. However, an error will be reported when the service provider starts because the service provider has registered on port 8761, but there is no eureka server on port 8761. , why is the address of the eureka server configured in the service provider's configuration file, and why does it also request registration from port 8761? This is because when the service provider registers with the eureka server on port 8080, it obtains the eureka server address configured by the eureka server itself. However, in the above eureka server configuration file, there is no eureka.client.serviceUrl.defaultZone configuration item, so the service The provider believes that the default http://localhost:8761/eureka link configuration used by the eureka server. To sum up, if the service provider does not report an error, you only need to add the configuration item on the eureka server side:

eureka.client.serviceUrl.defaultZone=http://localhost:8080/eureka

The above is the detailed content of Spring Cloud application eureka use. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn