課程中用到的注解器,希望有人能用自己的語言(自己的理解)概括一下。
@Component
@ConfigurationProperties
@RestController
@Autowired
@RequestParam
@PathVariable
@Entity
@Id
@GeneratedValue
@Component
@ConfigurationProperties
@RestController
@Autowired
@RequestParam
@PathVariable
@Entity
@Id
@GeneratedValue
2018-08-19
舉報
2018-08-20
理解不到位的地方請大家指正
@Component:
把pojo實例化,相當于配置文件中的<bean id="" class=""/>,需要在配置文件中引入component的掃描組件 <context:component-scan base-package=”com.imooc”>
@ConfigurationProperties:
獲取配置信息
@RestController:
相當于@ResponseBody + @Controller。@ResponseBody:將controller返回的對象轉換為Json數據。@Autowired:
注入外部資源
@RequestParam:
傳遞參數(value:參數名字,required:是否必須有參數,defaultvalue:請求中沒有同名參數時使用默認值)@PathVariable:
獲取url上的參數(可以是動態的)。
@Entity
指明實體Bean
@Id
聲明為主鍵
@GeneratedValue
主鍵生成策略,默認為自動增長