1. 程式人生 > >spring 常用註解解釋 持續更新

spring 常用註解解釋 持續更新

@Repository  : 資料訪問元件  也就是DAO層

@Autowired   : 可以對類成員變數,方法以及建構函式進行標註,完成自動壯派的工作,通過@Autowired的使用來消除get.set方法

@SpringBootApplication : 用在main方法之上,相當於@Configuration,@EnableAutoConfiguration,@ComponentScan 的組合,

@Configuration : 表示將該類左衛springboot配置檔案類

@EnableAutoConfiguration : 表示程式啟動的時候,自動載入springboot預設的配置

@ComponentScan : 表示程式啟動的時候,自動掃描當前包以及子包所有的類

@EnableTransactionManagement   : //啟用實物,要在對應方法之上加@Transactional

@Transactional  : 實質上是使用了JDBC的事物進行事務管理,是基於Spring的動態代理機制;必須放在public之上

@Component   :  放在DAO類之上,將該類納入到spring管理容器當中

@Before  :  ("execution(* springboot ..*.*(..))")    //執行springboot下的子包以及子子包的方法,在方法執行前呼叫

@Pointcut  : ("execution(* *.perform(..))")   //定義切點,標記方法

@AfterReturning   :  ("performance()")   //切點執行成功之後執行  

@AfterThrowing   : ("performance()")    //切點丟擲異常後執行