首页 > 移动平台 > 详细

springboot整合测试_SpringBootApplication注解和RestController注解

时间:2020-03-27 22:43:17      阅读:65      评论:0      收藏:0      [点我收藏+]

一、整合测试

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
</dependency>
@Before
public void test01(){
    System.out.println("aaaaaa");
}
@Test
public void test02(){
    System.out.println("bbbbbb");
}
@After
public void test03(){
    System.out.println("cccccc");
}

 

二、SpringBootApplication注解

//@EnableAutoConfiguration
//@ComponentScan("com.wuxi")
//********等价********
@SpringBootApplication(scanBasePackages = {"com.wuxi"})//默认情况下扫描的是当前包及当前包的子包

 

三、RestController注解

//@ Controller
@RestController // Restful风格,等价@Controller+@ResponseBody
public class IndexController {
    @RequestMapping("/lin/{id}")
    // @ResponseBody
    public Object requestFun(@PathVariable String id) {
        return id;
    }
}

 

springboot整合测试_SpringBootApplication注解和RestController注解

原文:https://www.cnblogs.com/linding/p/12584439.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!