在没有web.xml的情况下标记应用程序可分发用于Tomcat会话复制

vto*_*tor 6 java xml session spring tomcat

我有基于Spring的应用程序,并使用编程方法(AbstractAnnotationConfigDispatcherServletInitializer)进行应用程序配置.

为了使tomcat会话复制工作,我需要使用tag 标记'app distributable,但是正如我所提到的,我正在使用编程风格,例如<distributable/>web.xml

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);

        }
    }
Run Code Online (Sandbox Code Playgroud)

我找不到任何关于如何使用Spring配置的文档,所以我的问题是,是否可以在没有web.xml的情况下拥有可分发的应用程序?我无法将所有配置移动到web.xml,所以任何帮助都表示赞赏.

M. *_*num 6

您可以从基于Java的配置中设置几个选项,其中一个是<distributable />另一个选项error-pages.

为此你仍然需要一个web.xml,只需创建一个尽可能空的web.xml,只包括<distributable />.其他所有内容都可以保留在基于Java的配置中.

<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>
Run Code Online (Sandbox Code Playgroud)