其他
Spring Boot 注解大全,一键收藏!回城路上复习!
点击上方蓝色“程序猿DD”,选择“设为星标”
回复“资源”获取独家整理的学习资料!
一、注解 (annotations) 列表
二、注解 (annotations) 详解
package com.example.myproject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@RequestMapping(“/test”)
@ResponseBody
public String test(){
return”ok”;
}
@Controller
@RequestMapping(“/demoInfo”)
publicclass DemoController {
@Autowired
private DemoInfoService demoInfoService;
@RequestMapping("/hello")
public String hello(Map map){
System.out.println("DemoController.hello()");
map.put("hello","from TemplateController.helloHtml");
//会使用hello.html或者hello.ftl模板进行渲染显示.
return"/hello";
}
}
package com.kfit.demo.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(“/demoInfo2”)
publicclass DemoController2 {
@RequestMapping("/test")
public String test(){
return"ok";
}
}
@Value(value = “#{message}”)
private String message;
@Autowired
@Qualifier(value = “demoInfoService”)
private DemoInfoService demoInfoService;
三、JPA 注解
四、springMVC 相关注解
@RequestParam
String a =request.getParameter(“a”)。
RequestMapping(“user/get/mac/{macAddress}”)
public String getByMacAddress(@PathVariable String macAddress){
//do something;
}
五、全局异常处理
﹀
﹀
﹀
推荐加入
最近热门内容回顾 #技术人系列