2016년 7월 19일 화요일

Client side loadBalacing with eureka(1)

You can implement loadbalance client by using ribbon and eureka.
First of all, you can set the eureka server.

- Structure





















- pom.xml



    4.0.0

    org.blog.test
    eureak-load-server-project
    1.0-SNAPSHOT


    
        org.springframework.boot
        spring-boot-starter-parent
        1.2.8.RELEASE
         
    

    
        UTF-8
        1.8
    

    
        
            org.springframework.cloud
            spring-cloud-starter-eureka-server
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
            org.springframework.boot
            spring-boot-starter-actuator
        

    

    
        
            
                org.springframework.cloud
                spring-cloud-starter-parent
                Angel.SR4
                pom
                import
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    




- application.properties

server.port=8761
spring.application.name=eureka-server


- ServerApplication.java

package org.blog.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableEurekaServer
@RestController
public class ServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }

    @RequestMapping("/server/info")
    public String getServerInfo() {
        return "eureka-server";
    }
}

댓글 없음 :

댓글 쓰기