Font size
Worksheetsspring boot 測驗
Total questions: 15
Worksheet time: 14mins
Spring Boot 如何幫助簡化應用程式的開發流程?
限定使用外部伺服器來運行應用
仰賴開發者手動編輯大量的 XML 配置文件
提供自動配置、內嵌伺服器,並減少樣板代碼
支持微服務架構,但不提供監控和健康檢查的功能
Spring Boot 中,@SpringBootApplication 注解等效於哪三個注解的組合?
@Configuration, @EnableAutoConfiguration, @ComponentScan
@RestController, @EnableAutoConfiguration, @ComponentScan
@Controller, @Service, @Component
@Repository, @Controller, @Service
IoC 的全稱為 ___a___,IoC 的意思為 ___b___
Immediate or Cancel(立即成交或取消)
將 Object 的控制權,交給外部的 Spring 容器來管理
將 Object 的控制權,留下來自己管理
創建 Bean 的方法有哪些?
使用 @Configuration + @Bean
使用 @PostConstruct
使用 @Autowired
使用 @Component
初始化 Bean 的方法有哪些?
使用 @Component
使用 @Autowired
使用 @PostConstruct
實現 InitializingBean interface 的 afterPropertiesSet() 方法
AOP 的全稱為 ___a___ ,AOP 的意思為 ___b___
Automatic Operation(自動運轉機制)
將共同邏輯複製到所有方法裡面,讓每一個方法自己去處理
@Aspect 的用途為?
將 Class 變成由 Spring 容器所管理的 Bean,並自動注入依賴
表示這個 Class 是用來設定 Spring 的 Java Config
用於在 Spring MVC 中定義一個 Controller,處理 HTTP 請求
宣告這個 Class 是一個切面
下列哪一個「不是」 Spring AOP 常見的應用?
Log 記錄
權限驗證
管理 Spring 容器
統一的 Exception 處理
@RequestMapping 的主要用途為?
將 Class 變成由 Spring 容器所管理的 Bean
將 url 路徑對應到方法上
讀取 Spring Boot 設定檔(application.properties)中指定的 key 的值
將 HTTP 請求的參數自動綁定到方法的參數上
下列哪一個「不是」設計出 RESTful API,需要同時滿足的三大要素?
在 request header 中帶上 Authorization header,用作身份驗證
使用 http method 表示動作
使用 url 路徑描述資源之間的階層關係
response body 返回 json 或是 xml 格式
若想要在加上「@RequestBody」的 student 參數裡面,使用 @NotNull... 這類的驗證請求參數的註解的話,則需要在 student 參數前面加上 (a) ?
若想要在加上「@PathVariable、@RequestParam、@RequestHeader」的參數上,使用 @NotNull... 這類的驗證請求參數的註解的話,則需要在這個 Class 上加上 ______?
@Valid
@Valided
@Validated
@Validation
@ControllerAdvice 的底層是使用 Spring IoC 實作的,所以才能夠統一的去管理所有 Controller 所噴出的 Exception ?
正確
錯誤
攔截器 Interceptor 的前置處理功能為?
統一管理 Controller 所拋出的 Exception 並返回統一的錯誤響應
根據 HTTP request 的類型(如 GET、POST)動態選擇對應的 Controller 方法執行
改變 Controller 方法執行完畢後的返回結果,修改 response 的內容
決定要不要允許這次的 HTTP request 通過,進到 Controller 裡去執行對應的方法
以下關於 HandlerInterceptor 的 preHandle 方法描述何者錯誤?
preHandle 方法返回 false,表示「拒絕」 這次 http request 通過
preHandle 方法返回 true,表示「允許」這次 http request 通過
preHandle 方法將在 controller 處理之前進行調用
preHandle 方法可用來修改 HTTP request 的 body 內容,並影響後續 Controller 的處理
