Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Custom error handling for 404 requests.
import io.micronaut.http.annotation.*;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.server.exceptions.ExceptionHandler;
import javax.inject.Singleton;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpStatus;
import io.micronaut.web.router.exceptions.NoRouteFoundException;
@Singleton
class NotFoundHandler implements ExceptionHandler<NoRouteFoundException, HttpResponse> {
@Override
public HttpResponse handle(HttpRequest request, NoRouteFoundException exception) {
return HttpResponse.status(HttpStatus.NOT_FOUND).body("Custom 404 Not Found");
}
}Micronaut is a modern, JVM-based full-stack framework for building modular, easily testable microservices and serverless applications. It emphasizes low memory footprint, fast startup, and compile-time dependency injection.
Origin & Creator
Micronaut was created by Object Computing, Inc. (OCI), with Graeme Rocher as the lead architect, first released in 2018.
Industrial Note
Micronaut is optimized for microservices, serverless deployments, and environments where fast startup, low memory usage, and reactive I/O are critical.