Eureka server interface can be customized, and the way is relatively simple, let’s see how to change.

Within some companies, the service registry interface may need to be fully customized, carrying some of the company’s features and elements. If so, this section can help you. See the Open Eureka Server service I’ve exposed.

Create the Eureka Server project

Use the IDEA development tool to create a SpringBoot project and add dependencies to pom.xml as follows:

< properties > < Java version > 1.8 < / Java version > < spring - cloud. Version > Hoxton. RC2 < / spring - cloud. Version > < / properties > <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <dependencyManagement>  <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>Copy the code

Enable the Eureka Server

We use the @enableEurekaserver annotation in the startup class XxxApplication to enable the Eureka management side, as shown below:

/** * Custom EurekaServer management interface ** @author */ @springBootApplication @enableEurekaserver public class CustomizeEurekaManagePageApplication { public static void main(String[] args) { SpringApplication.run(CustomizeEurekaManagePageApplication.class, args); }}Copy the code

Configure the service

Next, add the Eureka configuration information to the application.yml configuration file, as shown below:

Spring: Application: name: customize-eureka-manage-page # eureka configuration Eureka: client: service-url: defaultZone: http://127.0.0.1:${server.port}/eureka/ fetch-registry: false register-with-eureka: false server: port: 10000Copy the code

Custom page

The tempaltes.eureka directory can be found in the spring-cloud-Netflix-Eureka-server-xx.xx.xx. jar dependency file, as shown in the following figure:

Templates. Eureka deposited Erueka directory Server administration page template file, we can copy out a template file into the current project resources/templates/eureka directory, and then customize interface.

  • header.ftlh: Top menu navigation template page
  • lastn.ftlh: Service registration record template page
  • navbar.ftlh: Navigation bar Information template page
  • status.ftlh: Basic status template page of the server where the service is located

We found the navbar. FTLH file, which is a page for Eureka Server to display System information, service registration list and basic information of the service Server on the home page. We simply added a line of information to the first table under the System Status category, as shown below:

< tr > < td > programmer heng yu young < / td > < td > < img SRC = "http://blog.yuqiyu.com/images/profile2.png" width = "400 px" / > < / td > < / tr >Copy the code

See the effect

To start or restart the project, visit http://127.0.0.1:10000 and see the result as shown below:

conclusion

You can customize the Eureka Server interface by modifying the templates. Eureka directory

Code sample

The sample source code for this article is available at customize-Eureka-manage-Page:

  • Gitee:https://gitee.com/hengboy/spring-cloud-chapter

Author’s Personal blog

Use the open source framework ApiBoot to help you become an Api service architect