記錄下一些常用注解

@RestController 和 @RequestMapping 注解是Spring MVC注解

@EnableAutoConfiguration

@SpringBootApplication 注解等價于以默認屬性使用 @Configuration , @EnableAutoConfiguration 和 @ComponentScan 。

@Profile
Spring Profiles提供了一種隔離應(yīng)用程序配置的方式,并讓這些配置只能在特定的環(huán)境下生效。任何@Component或@Configuration都能被@Profile標記,從而限制加載它的時機。

@Profile("production")

@ResponseBody
@Component:
@AutoWired
@RequestParam:
@PathVariable: 路徑變量。
@value注解來讀取application.properties里面的配置

全局處理異常的: @ControllerAdvice: 包含@Component??梢员粧呙璧健?br> 統(tǒng)一處理異常。

@ExceptionHandler(Exception.class): 用在方法上面表示遇到這個異常就執(zhí)行以下方法。

在SpringBootApplication上使用@ServletComponentScan注解后,Servlet、Filter、Listener可以直接通過@WebServlet、@WebFilter、@WebListener注解自動注冊,無需其他代碼。

@ConfigurationProperties(prefix = "httpApi.crm")
@ConfigurationProperties

@JsonInclude @JsonInclude(value=Include.NON_NULL)這個注解的意思是說,在序列化的過程中,如果對象的某個屬性的值為空null,則這個屬性就不會出現(xiàn)在json中;可能是前端這么要求,也可能是減少數(shù)據(jù)傳輸流量的要求;

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")private Date birthday;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容