java – 嵌入式Jetty 8.x / Spring MVC / WebApplicationInitial
有没有人有以下的工作样本:
>嵌入式Jetty 8.x应用程序 我已经尝试了所有可能的组合,但我不能让它工作.我发现的大多数嵌入式jetty示例都基于7.x或仍然使用XML配置文件.我现在获得的最佳设置是创建WebAppContext并将配置设置为AnnotationConfiguration.这在控制台上显示实际发生了某些事情,但它无法找到我的WebApplicationInitializer类,而它肯定在类路径上.这是基于Jetty 8.1.4和Spring 3.1.2. 出于测试目的,WebApplicationInitializer类没有做太多工作,它只在onStartup方法中打印一些内容来检查是否正在加载它. 谢谢! 解决方法
你看到这个问题:
Spring 3.1 WebApplicationInitializer & Embedded Jetty 8 AnnotationConfiguration?
我不能分享我的代码,但这里有一些代码可以帮助你: 在web.xml <!-- Java-based Spring container definition --> <context-param> <param-name>contextClass</param-name> <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> </context-param> <!-- Location of Java @Configuration classes that configure the components that makeup this application --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>com.workable.config</param-value> </context-param> 清空application-config.xml: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> </beans> Spring WebMVCConfig: /** * Spring MVC Configuration. * */ @Configuration @EnableWebMvc @EnableAsync @EnableScheduling public class WebMvcConfig extends WebMvcConfigurerAdapter { } /** * Main configuration class for the application. * Turns on @Component scanning,loads externalized application.properties. */ @Configuration @ComponentScan(basePackages = { "com.workable" },excludeFilters = {@Filter(Configuration.class)}) public class MainConfig { ... } Lib版本: <spring.version>3.1.2.RELEASE</spring.version> <jetty.version>8.1.5.v20120716</jetty.version> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |