在没有web.xml的情况下标记应用程序可分发用于Tomcat会话复制 [英] Marking application without web.xml distributable for Tomcat session replication
问题描述
我有基于Spring的应用程序并使用编程方法( AbstractAnnotationConfigDispatcherServletInitializer
)进行应用程序配置。
I have Spring based application and using programmatic approach (AbstractAnnotationConfigDispatcherServletInitializer
) for app configuration.
要使tomcat会话复制工作,我需要'标记'app distributable 使用 web.xml中的
,但正如我所提到的,我正在使用程序化风格,例如< distributable />
标记
To make tomcat session replication work I need to 'mark' app distributable using <distributable/>
tag in web.xml
, however as I mentioned I am using programmatic style, e.g.
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
String activeProfile = activeProfile();
if (isNotEmpty(activeProfile)) {
servletContext.setInitParameter("spring.profiles.active", activeProfile);
}
super.onStartup(servletContext);
}
}
我找不到任何文档关于如何使用Spring配置来实现它,所以我的问题是,是否有可能在没有web.xml的情况下拥有可分发的应用程序?我无法将所有配置移动到web.xml,所以任何帮助都表示赞赏。
I can't find any docs about how to do it using Spring configs, so my question here is that, Is it possible to have distributable app without having web.xml? I can't move all configs to the web.xml, so any help is appreciated.
推荐答案
有几个选项你不能从基于Java的配置设置,其中一个是< distributable />
另一个是错误页面
。
There are several option you cannot set from Java based configuration, one of them is <distributable />
another is the error-pages
.
为此你还需要 web.xml
,只需创建一个尽可能为空的 web.xml
,仅包含< distributable />
。其他所有内容都可以保留在基于Java的配置中。
For that you still need a web.xml
, just create an as empty as possible web.xml
and only include <distributable />
. Everything else can remain in Java based configuration.
<web-app
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<distributable />
</web-app>
这篇关于在没有web.xml的情况下标记应用程序可分发用于Tomcat会话复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!