spring modules to build a multi-server Eureka

1. Create a module and two Eureka_user_service_2000 a Eureka_order_serice_3000 customer service side of (below only one of their own to change what you can)

In the pom

<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

 

 

3. The main configuration and the configuration file type

allication.yml 中

Eureka: 
  Client: 
    serviceUrl: 
      defaultzone: HTTP: // localhost: 1000 / Eureka / # Registration Center Address 
Server: 
  Port: 2000 
the Spring: 
  the Application: 
    name: the User -server

 

Main configuration class

package cn.jiedada;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@SpringBootApplication
@EnableEurekaClient
public class Application {
    public static void main(String[] args) {
        new SpringApplicationBuilder(Application.class).web(true).run(args);
    }

}

controller

package cn.jiedada;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UuserController {
    @RequestMapping("/")
    public String home() {
        return "Hello world";
    }
}

You must turn on the server side to the client page using the following success

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/xiaoruirui/p/11925717.html