一般Log4j配置在web.xml中,在单元测试时,不需要启动Tomcat,所有Log4j找不到配置文件

 Juint整合Log4j

在测试类中手动加载 配置文件

PropertyConfigurator.configure("src/main/webapp/WEB-INF/log4j.properties");

DOMConfigurator.configure("src/main/webapp/WEB-INF/log4j.xml");

参数相对与项目 目录

 Juint整合Log4j

单元测试整合Srping使用注解

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath*:/applicationContext.xml",
"classpath*:/applicationUntil_Config.xml",
"classpath*:/spring-datasource.xml" })

 

相关文章:

  • 2021-12-23
  • 2022-01-21
  • 2021-11-28
  • 2021-12-21
  • 2021-12-11
  • 2021-08-13
  • 2022-12-23
猜你喜欢
  • 2022-01-22
  • 2022-01-29
  • 2021-11-25
  • 2021-12-23
  • 2022-02-23
  • 2021-07-17
  • 2021-08-15
相关资源
相似解决方案