@JsonIgnore
作用:在json序列化時將java bean中的一些屬性忽略掉,序列化和反序列化都受影響。
使用方法:一般標記在屬性或者方法上,返回的json數據即不包含該屬性。
Hibernate 註解:
@JSONField(serialize = false)
如果註解失效,可能是因爲你使用的是fastJson,嘗試使用對應的註解來忽略字段,使用方法一樣。
@Column(unique = true)
unique=true是指這個字段的值在這張表裏不能重複,所有記錄值都要唯一,就像主鍵那樣;
nullable=false是這個字段在保存時必須有值,不能還是null值就調用save去保存入庫;
Dao層註解:@Repository
Service層註解:@Service
Controller層註解:@Controller @RestController
【@RestController相當於@Controller+@ResponseBody兩個註解的結合】
1.使用@Controller 註解,在對應的方法上,視圖解析器可以解析return 的jsp,html頁面,並且跳轉到相應頁面
2.若返回json等內容到頁面,則需要加@ResponseBody註解。
swagger註釋:
協議集描述@Api:用於controller類上
協議描述@ApiOperation:用在controller的方法上
@GetMapping
是組合註解,是@RequestMapping(method =RequestMethod.GET)的縮寫。
@PostMapping
是組合註解,是@RequestMapping(method =RequestMethod.POST)的縮寫。
參數綁定註解詳解:
@PathVariable
當使用@RequestMapping URI template 樣式映射時, 即 someUrl/{paramId}, 這時的paramId可通過 @Pathvariable註解綁定它傳過來的值到方法的參數上。
示例代碼:
@RequestParam
示例代碼:
Spring如何獲取配置在application.properties文件中屬性的值?**
通過 @Value("${com.springboot.name}")
註解的方式