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

spring boot 配置HTTPS代碼實(shí)例

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

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

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;
/**
* 擴(kuò)展: 并將 http 自動(dòng)轉(zhuǎn)向 https
* @Description:類說(shuō)明:
* @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端口來(lái)供http訪問(wèn)(PB,kingdee)
		connector.setSecure(false);
		//輸入:my.com,跳到: http:// www.my.com
		connector.setRedirectPort(8095);
		//自動(dòng)重定向到8095,443端口
		return connector;
	}
}

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

相關(guān)文章

最新評(píng)論

临泽县| 信丰县| 平罗县| 阿拉善盟| 隆安县| 中宁县| 葵青区| 堆龙德庆县| 福安市| 江源县| 若尔盖县| 康定县| 湖口县| 宁强县| 新干县| 京山县| 友谊县| 新邵县| 云梦县| 阿图什市| 罗定市| 合水县| 和顺县| 岳池县| 南陵县| 浦江县| 永安市| 东宁县| 南投市| 股票| 海盐县| 浑源县| 景宁| 依安县| 万全县| 西吉县| 夹江县| 剑河县| 永兴县| 神木县| 盐城市|