本文介绍了Spring Boot 嵌入式 tomcat 自定义领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这个问题:嵌入式tomcat spring boot
但是,就解决方案而言,这还有很多不足之处,目前我有以下代码可以启用 SSL:
I am aware of this question: embedded tomcat spring boot
however this leaves much to be desired as far as a solution is concerned, Currently I have the following code which works to enable SSL:
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers( (connector) -> {
connector.setPort(8443);
connector.setSecure(true);
connector.setScheme("https");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
protocol.setSSLEnabled(true);
protocol.setKeystoreFile(keystore);
protocol.setKeystorePass(password);
protocol.setKeystoreType("jks");
protocol.setKeyAlias(alias);
}
)
我的问题是,如果我有一个在 XML 中看起来像这样的 Realm:
My question is this, if I have a Realm that looks like this in XML:
<Realm classname="foo.bar.baz | bing.bang.bong"
var1 = "xyz"
var2 = "123"
/>
如何使用嵌入式 tomcat 重新创建它?
How do I recreate that with embedded tomcat?
推荐答案
尝试使用 ContextCustomizer 而不是 ConnectorCustomizer
Try using the ContextCustomizer instead of the ConnectorCustomizer
tomcat.addContextCustomizers( (context) -> {
context.setRealm(...);
}
)
这篇关于Spring Boot 嵌入式 tomcat 自定义领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!