Java 學習記錄134 — 員工管理系統專案練習-Creating Custom Business Exception

src/main/java/exception 新增檔案

package exception;import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends RuntimeException {
public static final long serialVersionUID = 1L;
public ResourceNotFoundException(String message) {


返回給客戶端對應的狀態 HttpStatus.NOT_FOUND




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store