Java 春季4&x2B;GWT 2.6.0+;最小XML配置

Java 春季4&x2B;GWT 2.6.0+;最小XML配置,java,xml,spring,gwt,configuration,Java,Xml,Spring,Gwt,Configuration,我想使用springmvc和GWT创建web应用程序。主要目的是将XML配置最小化。我知道如何在没有XML配置的情况下设置纯springmvc应用程序(使用@configuration和AbstractAnnotationConfigDispatcherServletInitializer而不是web.XML),但我不知道如何使用GWT实现同样的效果。我试图在void onStartup(ServletContext container)方法中将手动org.spring4gwt.server.S

我想使用
springmvc
GWT
创建web应用程序。主要目的是将
XML
配置最小化。我知道如何在没有
XML
配置的情况下设置纯
springmvc
应用程序(使用
@configuration
AbstractAnnotationConfigDispatcherServletInitializer
而不是web.XML),但我不知道如何使用
GWT
实现同样的效果。我试图在
void onStartup(ServletContext container)
方法中将手动
org.spring4gwt.server.SpringGwtRemoteServiceServlet
添加到
ServletContainer
中的
void onStartup(ServletContext container)
中,但应用程序似乎忽略了我的类
WebAppStarter
扩展
AbstractAnnotationConfigDispatcherServletInitializer
(我只是将syser放在
WebAppStarter
的构造函数中,在纯
Spring MVC
应用程序中,它在标准err上打印一些内容,但在
GWT
中,标准err上没有打印任何内容)

以下是我的配置:

public class WebAppStarter extends AbstractAnnotationConfigDispatcherServletInitializer {

    public WebAppStarter() {
        System.err.println("======================> WEB_APP_STARTER");
    }

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[0];
    }

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

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

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

        ServletRegistration.Dynamic testServlet = container.addServlet("gwtServlet", new SpringGwtRemoteServiceServlet());
        testServlet.addMapping("/TestModule/springGwtServices/*");
    }

}

@Configuration
@EnableWebMvc
@ComponentScan(BASE_SPRING_COMPONENT_SCAN_PACKAGE_NAME)
public class WebAppConfiguration {  

}
公共类WebAppStarter扩展了AbstractAnnotationConfigDispatcherServletInitializer{
公共WebAppStarter(){
System.err.println(“======================>WEB应用程序启动程序”);
}
@凌驾
受保护类[]getRootConfigClasses(){
返回新类[0];
}
@凌驾
受保护类[]getServletConfigClasses(){
返回新类[]{WebAppConfiguration.Class};
}
@凌驾
受保护的字符串[]getServletMappings(){
返回新字符串[]{”/“};
}
@凌驾
启动时公共void(ServletContext容器)引发ServletException{
超级启动(集装箱);
ServletRegistration.DynamicTestServlet=container.addServlet(“gwtServlet”,新的SpringWTremoteServiceServlet());
addMapping(“/TestModule/springGwtServices/*”);
}
}
@配置
@EnableWebMvc
@组件扫描(基本\u弹簧\u组件\u扫描\u包\u名称)
公共类WebAppConfiguration{
}
我没有applicationContext.xml

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    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"
    version="3.0">

</web-app>

有什么想法吗?有可能实现吗


谢谢

看起来您已经熟悉了编写SpringMVC控制器(例如,或)


然后在一个单独的UI项目中,您可以与这些服务进行交互(例如)。

经过一些搜索,现在看来,
GWT
SDK中嵌入的
Jetty
配置不支持
Servlet 3.0
web.xml-less配置。我发现了以下问题:以及 因此,目前的解决方案是使用外部服务器(如
tomcat
-使用
-noserver
模式),但您失去了嵌入式
Jetty
的一些好处(作为开发模式)


一些解决方案是在
Eclipse
下的开发模式下配置
Tomcat
(更多信息),但我没有使用它,所以我不知道这是否有效。

这可能没有帮助。但您是否考虑过不与服务/控制器共同部署UI?而是让GWT项目通过REST调用进行交互,可以是w/RequestBuilder,也可以是w/RestyGwt?老实说,我不知道这种方法是如何工作的(通过REST).对我来说,用Java(而不是JavaScript)编写UI很重要。这个解决方案支持这个吗?