A Spring Boot starter provides all the necessary components, filters, and exception handling when using Spring MVC in enterprise applications.
The project uses Java 21
By default, a base exception handler is defined to process predefined exceptions and return a response which
adheres to RFC 7807 specification.
Extending BaseHttpExceptionHandler
class allows you to simplify the handling of your domain exception, e.g.
public class EntityNotFoundException extends RuntimeException {
public EntityNotFoundException(String message) {
super(message);
}
}
@RestControllerAdvice
public class HttpExceptionHandler extends GlobalHttpExceptionHandler {
@ExceptionHandler(EntityNotFoundException.class)
public ProblemDetail handleEntityNotFoundException(final EntityNotFoundException exception) {
return handleCustomException(exception, HttpStatus.NOT_FOUND);
}
}
TODO: Fill this section when the bom is ready
TODO: Once the bom is imported, adjust the example to add the dependency without a version
<dependencies>
<dependency>
<groupId>com.petromirdzhunev.libraries</groupId>
<artifactId>web-server-spring-boot-starter</artifactId>
<version>${latest-web-server-spring-boot-starter-version}</version>
</dependency>
</dependencies>
mvnd versions:set -DnewVersion=$(mvnd -B help:evaluate -Dexpression=project.version -DforceStdout | grep -E "^[0-9]+\.[0-9]+\.[0-9]+")-SNAPSHOT
(cd .. && mvnd -B -pl .,web-server-spring-boot-starter clean install)
Go to the project where web-server-spring-boot-starter
library is used.
Run the following command to point to the SNAPSHOT
version:
mvnd versions:use-latest-snapshots -Dincludes=com.petromirdzhunev:web-server-spring-boot-starter -DallowMajorUpdates=true -DallowMinorUpdates=true
When you finish the development you can revert to the previous version by running:
mvnd versions:revert -Dincludes=com.petromirdzhunev:web-server-spring-boot-starter