![](/img/trans.png)
[英]How to prevent the SpringJUnit4ClassRunner load all @Configuration classes
[英]SpringJUnit4ClassRunner to pick up specific logback configuration
有没有办法指定要在Spring运行的JUnit中使用的logback配置文件?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/my/app/springConfiguration.xml")
public class MyTest {
private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
@Autowired
Something something;
}
现在,我有了logback.xml和其中的多个。 有一个应该在prod中运行,然后有一个我想要这个测试。 有一个简单的方法吗?
编辑:这个问题特定于我从Eclipse运行JUnit时的情况。 我正在使用Windows 7上的Eclipse 4.3。
将该位置作为JVM argurment传递给在eclipse中运行测试的配置。
-Dlogback.configurationFile="fullpathtofile\logback.xml"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.