Spring Boot War를 local Tomcat 서버에 이관
2021. 3. 8. 12:54ㆍJava/Spring Boot
SpringBootServletInitializer를 상속받도록 처리
SpringApplicationBuilder를 override
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;;
@SpringBootApplication
@RestController
public class DemoApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DemoApplication.class);
}
@GetMapping("/hello")
public String hello(@RequestParam(value="name", defaultValue="World") String name) {
return String.format("Hello %s!", name);
}
}
Tomcat 서버 server.xml에 Context 추가
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="demo-0.0.1-SNAPSHOT" path="/" reloadable="false"/>
'Java > Spring Boot' 카테고리의 다른 글
Spring Boot jsp 호출이 안되는 경우 (0) | 2021.03.10 |
---|---|
Spring Boot에서 html과 jsp 중 어느 것이 더 먼저 인식이 될까? (0) | 2021.03.10 |
Spring Boot Static 파일 등록 (0) | 2021.03.06 |
Spring Boot Project JRE 변경 (0) | 2021.03.06 |
Spring Boot JSP 한글 깨짐 조치 (0) | 2021.03.06 |