Spring Cloud Zuul 을 사용 하여 동적 경로 구현
1671 단어 프레임 워 크 기술
Zuul 은 여러 Amazon Auto Scaling Groups 에 대한 경로 요청 을 적 절 히 할 수 있 습 니 다.
우선 Maven 프로젝트 를 새로 만 들 고 다음 의존 도 를 추가 합 니 다.
org.springframework.cloud
spring-cloud-netflix
1.1.3.RELEASE
pom
import
org.springframework.cloud
spring-cloud-starter-hystrix
org.springframework.cloud
spring-cloud-starter-zuul
package com.pp.zuul;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@EnableZuulProxy
@SpringBootApplication
public class App {
public static void main( String[] args ) {
SpringApplication.run(App.class, args);
}
}
설정 파일:application.properties
package com.pp.zuul;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HomeController {
@RequestMapping("/index")
public Object index() {
return "index";
}
@RequestMapping("/home")
public Object home() {
return "home";
}
}