この質問を見ましたか: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>