导入spring-mock-version.jar和junit相关的jar包
创建一个基类继承 org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;并且重写方法getConfigLocations() 例如:
protected String[] getConfigLocations() {<br>??????? setAutowireMode(AUTOWIRE_BY_NAME); //设置自动注入模型<br>??????? setDependencyCheck(false); //如果遇到什么不稳定、不满意之类的异常,必须设置为false<br>??????? return new String[] {<br>??????? ??"classpath:context/context-persistence.xml",??? //测试数据源的配置文件<br>??????????????? "classpath:context/web/context-dao.xml" //dao类的bean文件<br>??????????? };<br>??? }
创建一个基类继承 org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;并且重写方法getConfigLocations() 例如:
protected String[] getConfigLocations() {<br>??????? setAutowireMode(AUTOWIRE_BY_NAME); //设置自动注入模型<br>??????? setDependencyCheck(false); //如果遇到什么不稳定、不满意之类的异常,必须设置为false<br>??????? return new String[] {<br>??????? ??"classpath:context/context-persistence.xml",??? //测试数据源的配置文件<br>??????????????? "classpath:context/web/context-dao.xml" //dao类的bean文件<br>??????????? };<br>??? }