An import-dependent:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.2.8.RELEASE</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12 </version> </dependency>
Second, the test:
@RunWith (. The SpringJUnit4ClassRunner class ) // Specify application context used to create a container @ContextConfiguration ( "CLASSPATH: file application-context.xml" ) public class RunWithTest { @Autowired Private the User User; @Test public void testCreatePerson () { the System. Out.println (User); } }