我正在构建一个Maven / Java / Spring网络应用程序,该应用程序还定义了几个junit测试。
我想保留src / main / resources / ApplicationContext.xml
...bulk of config...
,然后仅将特定于Web的内容放入此处,然后导入大量内容: src / main / webapp / WEB-INF / spring / appServlet / servlet-context.xml
<import resource="classpath:ApplicationContext.xml" /> <!-- want to get this working -->
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<!-- this is NOT the same as src/main/resources -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/pages directory -->
<!-- STS shows ERROR : Build path is Incomplete. Cannot find class file for javax/servlet.ServletContext -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
假设这可以正常工作,那么我需要使用@WebAppConfiguration注释测试,如下所示:
@WebAppConfiguration
public class TestDatabaseConnections {
@Autowired
TryThisService tryThisService;
...
我还缺少其他提示或技巧吗? 还是完全将大部分内容移到.... / servlet-context.xml内部,然后让@WebAppConfig处理测试的事情?
TIA,
code_warrior