< ! -- 下面两个是测试相关的jar包-- > 
< dependency> < groupId> . springframework< / groupId> < artifactId> - test< / artifactId> < version> 5.1 .5 . RELEASE < / version> 
< / dependency> 
< dependency> < groupId> < / groupId> < artifactId> < / artifactId> < version> 4.13 < / version> < scope> < / scope> 
< / dependency> 
import  com. imooc. spring. jdbc. entity.  Employee ; 
import  org. junit.  Test ; 
import  org. junit. runner.  RunWith ; 
import  org. springframework. beans. factory. annotation.  Autowired ; 
import  org. springframework. test. context.  ContextConfiguration ; 
import  org. springframework. test. context. junit4.  SpringJUnit4ClassRunner ; @RunWith ( SpringJUnit4ClassRunner . class ) 
@ContextConfiguration ( locations =  "classpath:applicationContext.xml" ) 
public  class  EmployeeDaoTest  { @Autowired private  EmployeeDao  employeeDao; @Test public  void  findById ( )  { Employee  employee =  employeeDao. findById ( 3308 ) ; System . out. println ( employee) ; } 
} 
import  com. imooc. spring. jdbc. entity.  Employee ; 
import  org. junit.  Test ; 
import  org. springframework. context.  ApplicationContext ; 
import  org. springframework. context. support.  ClassPathXmlApplicationContext ; public  class  EmployeeDaoTest  { @Test public  void  findById ( )  { ApplicationContext  context = new  ClassPathXmlApplicationContext ( "classpath:applicationContext.xml" ) ; EmployeeDao  employeeDao =  context. getBean ( "employeeDao" ,  EmployeeDao . class ) ; Employee  employee =  employeeDao. findById ( 3308 ) ; System . out. println ( employee) ; } 
}