스프링 부트는 기본적으로 톰캣을 내장하고 있다.
새로 시작하는 사람들에겐 설정할 단계가 줄어들어 편하겠지만
톰캣이 이미 깔려있거나 톰캣이 깔린 서버에 배포를 원하는 경우
외부 톰캣을 사용하도록 변경해야만 한다.
변경방법은 아래와 같이 build.gradle 파일을 수정한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
apply plugin: 'java' apply plugin: 'idea' apply plugin: 'spring-boot' // eclipse 를 제거 하고 eclipse-wtp와 war를 추가 //apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' apply plugin: 'war' |
그리고 Application.java 파일을 아래와 같이 변경한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
/* @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } */ @Configuration @ComponentScan @EnableAutoConfiguration public class Application extends SpringBootServletInitializer { // Used when launching as an executable jar or war public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } // Used when deploying to a standalone servlet container @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } } |
스프링 부트에서 외부 톰캣 사용하도록 변경