使用属性进行Spring Boot配置,仅允许配置一个连接器。您需要多个连接器,为此,您必须编写一个Configuration类。遵循中的指示
https://docs.spring.io/spring-boot/docs/1.2.3.RELEASE/reference/html/howto-
embedded-servlet-containers.html
您可以在下面找到通过属性配置https的有效示例,然后通过EmbeddedServletContainerCustomizer通过http进行配置
http://izeye.blogspot.com/2015/01/configure-http-and-https-in-spring-
boot.html?showComment=1461632100718#c4988529876932015554554
server: port: 8080 ssl: enabled: true keyStoreType: PKCS12 key-store: /path/to/keystore.p12 key-store-password: password http: port: 8079
@Configurationpublic class TomcatConfig {@Value("${server.http.port}")private int httpPort;@Beanpublic 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); } } };}}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)