Spring Java Config:没有web.xml的Tomcat部署

Tun*_*ska 7 spring tomcat maven maven-tomcat-plugin spring-java-config

我构建了一个没有任何XML的java配置的Spring MVC应用程序.我可以在笔记本电脑上部署和启动应用程序,没有任何问题.但是当我尝试在我的testserver(tomcat 7)上部署我的应用程序时,我收到以下消息:

HTTP Status 404 - The requested resource (/[application context]/) is not available.
Run Code Online (Sandbox Code Playgroud)

我使用Eclipse Maven插件构建我的应用程序.是否可以在没有web.xml的情况下部署应用程序,如果没有,哪个是我真正需要的基本web.xml?

Maven WAR插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>${maven.war.plugin.version}</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

WebAppInitializer:

@Order(value = 1)
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        super.onStartup(servletContext);
    }

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[] { HibernateConfig.class, SecurityConfig.class, HibernateDaoConfig.class };
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] { WebAppConfig.class };
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }

    @Override
    protected Filter[] getServletFilters() {
        return new Filter[]{};
    }
}
Run Code Online (Sandbox Code Playgroud)

更新:catalina.out

Feb 3, 2014 4:18:32 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/[appname]] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Feb 3, 2014 4:18:33 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/[appname]]
Feb 3, 2014 4:18:45 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive [appname].war
Run Code Online (Sandbox Code Playgroud)

Joe*_*oeG 1

如果还是没有解决,可能是Servlet版本的问题。Servlet 3.x API 需要能够通过编写 java 类来配置 java web 应用程序,而不是在 WEB-INF 文件夹中使用 web.xml 文件。

请参阅此处查看完整示例。