最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

spring boot 配置HTTPS代碼實例

 更新時間:2019年11月04日 10:45:43   作者:A漢克先生  
這篇文章主要介紹了spring boot 配置HTTPS代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

這篇文章主要介紹了spring boot 配置HTTPS代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

spring boot 版本是<version>1.5.8.RELEASE</version>

1.配置文件里,看下不要有空格=[不要有空格]

2.別名

================

server.port=8095
server.ssl.key-store=*.pfx
server.ssl.key-store-password=**
server.ssl.key-store-type=PKCS12
server.ssl.key-alias=alias//別名

代碼

import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 擴展: 并將 http 自動轉(zhuǎn)向 https
* @Description:類說明:
* @author: gzh
* @date: 2019年11月1日上午11:08:20
*/
@Configuration
public class HttpsConfiguration {
	@Bean
	public EmbeddedServletContainerFactory servletContainer() {
		TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(){
			protected void postProcessContext(Context context) {
				SecurityConstraint securityConstraint = new SecurityConstraint();
				securityConstraint.setUserConstraint("CONFIDENTIAL");
				SecurityCollection collection = new SecurityCollection();
				collection.addPattern("/*");
				securityConstraint.addCollection(collection);
				context.addConstraint(securityConstraint);
			}
		}
		;
		tomcat.addAdditionalTomcatConnectors(httpConnector());
		return tomcat;
	}
	@Bean
	public Connector httpConnector(){
		Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
		connector.setScheme("http");
		connector.setPort(8096);
		//表示用8080端口來供http訪問(PB,kingdee)
		connector.setSecure(false);
		//輸入:my.com,跳到: http:// www.my.com
		connector.setRedirectPort(8095);
		//自動重定向到8095,443端口
		return connector;
	}
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

咸宁市| 伊春市| 扎赉特旗| 海宁市| 毕节市| 洪泽县| 永登县| 民县| 那曲县| 吉木萨尔县| 宽甸| 西和县| 扎囊县| 定安县| 织金县| 盐城市| 西安市| 乳山市| 双江| 隆昌县| 邢台县| 镇康县| 杭锦旗| 江门市| 武宁县| 安岳县| 顺昌县| 威远县| 双鸭山市| 景泰县| 新泰市| 台中县| 巴林右旗| 广平县| 华亭县| 东乡| 华蓥市| 炉霍县| 错那县| 巴青县| 响水县|