Category: Spring Boot
-

Spring @Transactional is Not Magic: The Proxy Trap and Why Your Data Isn’t Safe
**Most developers treat @Transactional like a magic wand, but it is actually a proxy-based abstraction that is remarkably easy to break.** If you do not understand Java AOP, you are likely creating “zombie data” and performance bottlenecks without even knowing it. This post deconstructs the **self-invocation trap**, the **rollback myth of checked exceptions**, and why…
-

SLF4J, Logback, and Log4j: A Straightforward Guide to Java Logging
The Java logging ecosystem features SLF4J as a facade API, with Logback and Log4j2 as underlying implementations. Using SLF4J decouples application code from logging frameworks, allowing easy dependency changes. For most projects, SLF4J with Logback is recommended, while Log4j2 is better for high-performance needs, ensuring efficient logging strategies.
-

Flyway vs. Liquibase: Which Database Migration Tool is Right for You?
Database migrations are essential in modern application development for managing schema changes. Flyway offers simplicity with raw SQL migrations, suitable for single-database projects. In contrast, Liquibase provides advanced features like changelogs and rollback support, making it ideal for database-agnostic applications. The choice depends on project requirements and team expertise.
-

Mastering Data Validation in Java Applications
The article emphasizes the importance of validating data before it enters the database to prevent issues like NullPointerExceptions and inconsistent data. It advocates for early validation at both the controller and domain model levels, using annotations and custom validators for cleaner, simpler code, ultimately leading to enhanced application reliability.
-

Multi-Environment Configuration in Spring Boot
In this article, I talk about the importance of proper configuration in Spring Boot applications across multiple environments. By using Maven profiles, environment variables, and CI/CD pipelines, developers can maintain clean and flexible configurations. The goal is to ensure a seamless application experience whether running locally or in production, without the risk of misconfigurations.
-

Optimize Your API Using Memoization
In this article I describe how to use the memoization to optimize the response time of a request. I explain how to prepare the code and how to apply the solution.
-

Solve the CORS error with Spring Security
In this article I explain how to configure the CORS allowed frontend in a Spring Boot application when using Spring Security.
-

Spring Security 6 with JWT Authentication
Let’s see how to use Spring Security 6 with JWT Authentication. I will do it using the Web Filters to handle JWT requests and credentials requests.
-

Spring Security and Roles Authorization
In this article I will explain the difference between Authentication and Authorization. I will also explain how to implement the Authorization pattern with Spring Security. For that, I will use the @PreAuthorize annotation.
-

The CSRF Protection with Spring Security
In this article I will explain the CSRF attack, the Cross-Site Request Forgery attack. I will show how Spring Security can protect against this attack, in both a server side rendering server and with a separated frontend and the Cookie repository.
