티스토리 뷰
Framework/SpringBoot
[Spring Boot] Spring Boot 2.x Tomcat https-http 동시 사용 (Tomcat Ajp설정)
annajinee 2019. 4. 9. 12:13spring boot 1.3~1.5대에서는 아래 EmbeddedServletContainerCustomizer 가 사용가능하지만
2.x 대부터 지원을 안함 ㅠㅠ
package com.sweettracker.shoppingdiary.conf;
import org.apache.catalina.connector.Connector;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TomcatConfig {
@Value("${server.http.port}")
private int httpPort;
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory containerFactory =
(TomcatEmbeddedServletContainerFactory) container;
Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
connector.setPort(httpPort);
containerFactory.addAdditionalTomcatConnectors(connector);
}
}
};
}
}
Spring boot v2.1.0 에서 기동시 아래와 같은 에러 발생
java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/bind/Binder
에러 내용
2019-04-09 12:21:58.171 INFO 18188 --- [ main] c.s.s.ShoppingdiaryApplication : Starting ShoppingdiaryApplication on [Annaui-MacBookPro.local](https://annajinee.tistory.com/Annaui-MacBookPro.local) with PID 18188 (/Users/annakim/Documents/ShoppingDiary/target/classes started by annakim in /Users/annakim/Documents/ShoppingDiary)
2019-04-09 12:21:58.174 INFO 18188 --- [ main] c.s.s.ShoppingdiaryApplication : No active profile set, falling back to default profiles: default
2019-04-09 12:21:58.430 ERROR 18188 --- [ main] [o.s.boot.SpringApplication](https://annajinee.tistory.com/o.s.boot.SpringApplication) : Application startup failed
java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/bind/Binder
at [org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getExcludeAutoConfigurationsProperty(AutoConfigurationImportSelector.java:245)](https://annajinee.tistory.com/org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getExcludeAutoConfigurationsProperty(AutoConfigurationImportSelector.java:245))
at [org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getExclusions(AutoConfigurationImportSelector.java:239)](https://annajinee.tistory.com/org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getExclusions(AutoConfigurationImportSelector.java:239))
at [org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:122)](https://annajinee.tistory.com/org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:122))
at [org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:420)](https://annajinee.tistory.com/org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:420))
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:878)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:804)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:774)
at [org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)](https://annajinee.tistory.com/org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185))
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
at [org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)](https://annajinee.tistory.com/org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122))
at [org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)](https://annajinee.tistory.com/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693))
at [org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)](https://annajinee.tistory.com/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360))
at [org.springframework.boot.SpringApplication.run(SpringApplication.java:303)](https://annajinee.tistory.com/org.springframework.boot.SpringApplication.run(SpringApplication.java:303))
at [org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)](https://annajinee.tistory.com/org.springframework.boot.SpringApplication.run(SpringApplication.java:1118))
at [org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)](https://annajinee.tistory.com/org.springframework.boot.SpringApplication.run(SpringApplication.java:1107))
at [com.sweettracker.shoppingdiary.ShoppingdiaryApplication.main(ShoppingdiaryApplication.java:13)](https://annajinee.tistory.com/com.sweettracker.shoppingdiary.ShoppingdiaryApplication.main(ShoppingdiaryApplication.java:13))
Caused by: java.lang.ClassNotFoundException: [org.springframework.boot.context.properties.bind.Binder](https://annajinee.tistory.com/org.springframework.boot.context.properties.bind.Binder)
at [java.net.URLClassLoader.findClass(URLClassLoader.java:382)](https://annajinee.tistory.com/java.net.URLClassLoader.findClass(URLClassLoader.java:382))
at [java.lang.ClassLoader.loadClass(ClassLoader.java:424)](https://annajinee.tistory.com/java.lang.ClassLoader.loadClass(ClassLoader.java:424))
at [sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)](https://annajinee.tistory.com/sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349))
at [java.lang.ClassLoader.loadClass(ClassLoader.java:357)](https://annajinee.tistory.com/java.lang.ClassLoader.loadClass(ClassLoader.java:357))
... 21 common frames omitted
아래처럼 설정하면 ajp 포트 사용가능!
https 와 http 포트를 동시 사용할수있다 (spring boot 2.0 레퍼런스에 있음)
config 설정
package com.sweettracker.shoppingdiary.conf;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TomcatConfig {
@Value("${server.http.port}")
private int httpPort;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createAjpConnector());
return tomcat;
}
private Connector createAjpConnector() {
Connector ajpConnector = new Connector("AJP/1.3");
ajpConnector.setPort(httpPort);
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme("http");
return ajpConnector;
}
}
위와 같이 설정 시 Spring Boot 2.1 버전에서 사용 가능함
정상작동 확인 :)))
2019-04-09 12:31:22.861 INFO 18787 --- [ main] org.apache.coyote.ajp.AjpNioProtocol : Starting ProtocolHandler ["ajp-nio-8010"]
2019-04-09 12:31:22.866 INFO 18787 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 443 (https) 8010 (http) with context path ''
'Framework > SpringBoot' 카테고리의 다른 글
[Spring Boot] Ajp 에러- Invalid message received with signature (1) | 2019.04.09 |
---|---|
[Spring Boot] SpringBoot 2.x의 HikariCp 에러 정리 (0) | 2019.01.17 |
[SpringBoot] Spring REST API에 Swagger(스웨거)설정하기 (0) | 2017.07.26 |
[SpringBoot] Http를 Https로 전환/ 리다이렉트 시키기 (Redirecting HTTP to HTTPS in Spring Boot) (1) | 2017.07.24 |
[SpringBoot] Spring과 Spring Boot의 차이 (0) | 2017.07.12 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- https 동시사용
- 프록시 설정
- JPA란
- spring jpa
- entityfactory
- Spring
- nginx
- 의존성 사이클
- SSL
- 자바 가상머신
- JPA
- jpa 값타입
- spring boot 2.1
- angular2
- plugin
- tomcat Ajp
- spring boot 포트
- JPA 영속성관리
- entity type
- 플러그인
- 엔진엑스
- springboot
- spring boot
- AJP
- JPA 엔티티
- spring boot http
- HTTPS
- entitymanager
- HTTP
- exception종류
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함