springmvc @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:dao.xml"}) //类注解 springboot <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> @RunWith(SpringRunner.class) @SpringBootTest public class PostgisTest { @Resource TestGisMapper testGisMapper; @Test public void test () { System.out.println("333"); } }