1. 설정값 (application.yml)
tomcat:
ajp:
protocol: AJP/1.3
port: 18009
2. 클래스 생성 (ContainerConfig.java)
@Configuration
public class ContainerConfig {
@Value("${tomcat.ajp.protocol}")
String ajpProtocol;
@Value("${tomcat.ajp.port}")
int ajpPort;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createAjpConnector());
return tomcat;
}
private Connector createAjpConnector() {
Connector ajpConnector = new Connector(ajpProtocol);
ajpConnector.setPort(ajpPort);
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme("http");
return ajpConnector;
}
}
확인
2019-07-14 17:05:15.677 INFO 6609 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9099 (http) 18009 (http)
2019-07-14 17:05:15.700 INFO 6609 --- [ main] org.apache.coyote.ajp.AjpNioProtocol : Initializing ProtocolHandler ["ajp-nio-18009"]
2019-07-14 17:05:15.720 INFO 6609 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-14 17:05:15.721 INFO 6609 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-07-14 17:05:15.814 INFO 6609 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-14 17:05:15.815 INFO 6609 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1227 ms
2019-07-14 17:05:16.809 INFO 6609 --- [ main] org.apache.coyote.ajp.AjpNioProtocol : Starting ProtocolHandler ["ajp-nio-18009"]
2019-07-14 17:05:16.816 INFO 6609 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9099 (http) 18009 (http) with context path ''
참고