在Maven多模块Spring项目上的IntelliJ中运行JUnit测试

时间:2019-01-10 17:44:22

标签: java spring maven intellij-idea junit

我正在尝试直接在IntelliJ中运行JUnit测试。问题是,我的项目是使用Spring的Maven多模块项目。

这是我的主要应用程序上下文文件:

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

        <!-- Spring : Chargement des contextes de l'application -->
        <import resource="classpath*:spring/applicationContext-spring.xml"/>
        <import resource="classpath*:spring/applicationContext-fwk.xml"/>
        <import resource="classpath*:spring/applicationContext-model.xml"/>
        <import resource="classpath*:spring/applicationContext-service.xml"/>
        <import resource="classpath*:spring/applicationContext-facade.xml"/>
        <import resource="classpath*:spring/applicationContext-web.xml"/>

</beans>

我的JUnit测试在一个子项目中,无法直接访问applicationContext-fwk.xml,但是它需要该上下文中的bean。当然,使用Maven仍可以正常进行测试。怎么办?

0 个答案:

没有答案