ResourceNotFoundException.java
spring_boot/code/intermediate/src/main/java/com/example/demo/exception/ResourceNotFoundException.java
package com.example.demo.exception;
/**
* Thrown when a requested resource (e.g. product by ID) does not exist.
* <p>
* Handled by {@link GlobalExceptionHandler} to return HTTP 404 Not Found with a JSON body
* containing the exception message.
*/
public class ResourceNotFoundException extends RuntimeException {
/**
* @param message human-readable message (e.g. "Product not found: 123")
*/
public ResourceNotFoundException(String message) {
super(message);
}
}
相关文章
DemoApplication.java
DemoApplication.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/DemoApplication.java).
阅读文章 →CustomHealthIndicator.java
CustomHealthIndicator.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/actuator/CustomHealthIndicator.java).
阅读文章 →SecurityConfig.java
SecurityConfig.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/config/SecurityConfig.java).
阅读文章 →ProductController.java
ProductController.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/controller/ProductController.java).
阅读文章 →PublicController.java
PublicController.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/controller/PublicController.java).
阅读文章 →ProductCreateRequest.java
ProductCreateRequest.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/dto/ProductCreateRequest.java).
阅读文章 →