Spring????μ??????????
???????????? ???????[ 2014/8/28 14:28:02 ] ??????????????? ??????? ???????
??????????Spring??????£???????????????????
??????????spring?ж?Junit???????????
????????junit4??spring??jar?????????spring-test.jar????????????????
<span style="font-size:18px;"><span style="white-space:pre"> </span><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.1.RELEASE</version>
</dependency></span>
????????????????????AbstractJUnit4SpringContextTests????????????????????????????????????bean???
<span style="font-size:18px;"><span style="color:#ff0000;">@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:applicationContext.xml"})</span>
public class ReadDaoImplTest extends<span style="color:#ff0000;"> AbstractJUnit4SpringContextTests</span>{
@Resource ReadDao readDao;
@Test
public void getListTest(){
List<Client> clientList = readDao.getList("client.test"?? null);
for(Client c:clientList){
System.out.println(c.getVersionNum());
}
}
}
</span>
???????????????spring????????????????spring????
public class ReadDaoImplTest {
public static void main(String[] args){
ClassPathXmlApplicationContext context = <span style="color:#ff0000;">new ClassPathXmlApplicationContext("applicationContext.xml");</span>
context.start();
ReadDao fqaService = (ReadDao) context.getBean("readDao");
System.out.println(fqaService);
}
}
?????????????????????Ctrl+F11????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11