【Java 代码】
@RunWith(SpringJUnit4ClassRunner.class)// #加载配置文件@ContextConfiguration("file:web/WEB-INF/applicationContext.xml")public class UserControlTest extends AbstractJUnit4SpringContextTests { @Qualifier("userService") @Autowired private UserService userService; @Before public void setup() { } @Test public void testFindAll() throws Exception { userService.findAll(); }}
【顺带附上log4j配置】没啥技术含量,留着备份吧
file path: \src\log4j.properties
log4j.rootLogger=WARN, stdout, filelog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n# Output to the Filelog4j.appender.file=org.apache.log4j.FileAppender# 输出 pathlog4j.appender.file.File=./jfinal_demo.loglog4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH\:mm\:ss}%n[%p]-[Thread\: %t]-[%C.%M()]\: %m%n