Posts

Showing posts from September, 2024

Spring Boot - Debug Webflux reactive application in IDE

With Spring Boot Webflux reactive application, to debug and identify the unexpected exception thrown from a handler while handling http request, put a debug / break point in the following method of the class. This will quickly reveal the exception along with stacktrace with your favourite IDE Class: org.springframework.web.reactive.DispatcherHandler Method: handleRequestWith Have a breakpoint in the line after Mono<HandlerResult> resultMono = adapter.handle(exchange, handler)  and evaluate as  resultMono.block() Happy Debugging !!!

Spring Boot - Debug Web MVC application in IDE

With Spring Boot Web MVC application, to debug and identify the unexpected exception thrown from a controller while handling http request, put a debug / break point in the following method of the class. This will quickly reveal the exception along with stacktrace with your favourite IDE Class: org.springframework.web.servlet.DispatcherServlet Method: doService Have a breakpoint in the finally block and evaluate as request.getAttribute("org.springframework.boot.web.servlet.error.DefaultErrorAttributes.ERROR") Happy Debugging !!!

Spring Boot - Log generated SQL statement and query

To log and see the generated SQL statement and queries in Spring Boot application use the following properties in properties or yaml file. The properties allows to see the SQL from JPA (hibernate), JdbcTemplate (Core JDBC) and Liquibase layers of Spring Boot application. These settings adjust the logging level in logback for various layers in spring boot application. Using application.properties file logging.level.org.hibernate=TRACE logging.level.org.springframework.jdbc=TRACE logging.level.liquibase=TRACE Or using application.yml file logging : level : org : hibernate : TRACE springframework : jdbc : TRACE liquibase : TRACE