转自:http://blog.csdn.net/u010987379/article/details/52091790
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })
- @TestExecutionListeners( { DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class })
- @Transactional
- public class TestClass {
-
@Resource
private ServiceOne serviceOne;
-
-
-
-
- @Test
- public void t1(){
-
- }
- }
[转]使用@Test 也可以从spring容器中获取依赖注入
原文:http://www.cnblogs.com/handsomeBoys/p/7657852.html