测试文件的输出停止。它没有运行@Before。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/spring-tests.xml"})
public class SomeMapperTest{
private static Logger logger;
@BeforeClass
public static void setupLog4j(){
final String LOG4J_FILE = "test-log4j.properties";
URL log4jFile = someMapperTest.class.getClassLoader().getResource(LOG4J_FILE);
PropertyConfigurator.configure(log4jFile);
logger = Logger.getLogger(SomeMapperTest.class);
logger.info("SomeMapperTest Logger initialized successfully!");
}
@Autowired
SqlSessionTemplate sqlSession;
@Autowired
SomeMapper someMapper;
@Before
public void setupclass()
{
/doesn't make it here
someMapper = sqlSession.getMapper(SomeMapper.class);
}//...
注释掉类上面的两个注释会导致它运行但是它不会获得sqlSession。有什么东西是我遗失的吗?谢谢!
编辑: 这是test-log4j.properties文件
log4j.logger.dir=INFO, stdout
log4j.logger.com.sun=DEBUG, stdout
log4j.logger.java.sql=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%c:%L) - %m%n
log4j.additivity.com.eds=false