我正在使用 Jersey 对 RESTful Web 服务执行验收测试。看起来好像我的 applicationContext.xml 在客户端加载时没有被加载。我看到以下日志输出:
INFO: Using default applicationContext
泽西岛在找不到我的文件时会加载这个“默认”文件吗?或者这是否表明找到了我的文件?
@ContextConfiguration(locations={"/applicationContext.xml", "/applicationContextTest.xml"})
public class BaseResourceTest extends JerseyTest {
final static URI baseUri = UriBuilder.fromUri( "http://localhost" ).port( 9998 ).build();
public BaseResourceTest() throws Exception {
super(new WebAppDescriptor.Builder("xxx.yyy.zzz").contextPath(baseUri.getPath())
.contextParam(
SpringServlet.CONTEXT_CONFIG_LOCATION, "classpath:applicationContextTest.xml" )
.servletClass(SpringServlet.class )
.contextListenerClass( ContextLoaderListener.class )
.build());
}
.......
some tests
.......
}
我的 web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>xxx.yyy.LoggingAssuranceListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>xxx.yyy.zzzz</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.WadlGeneratorConfig</param-name>
<param-value>xxx.yyy.zzz.BroadsoftWadlGeneratorConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>