One thing I’ve learned building backend systems: Audit logging always starts as a “simple requirement” …and ends up being a complex subsystem. - Who changed what? - When did it happen? - Can we query it efficiently? Most teams either: 1. Over-engineer it 2. Or build something they regret later So I decided to build it properly once. Introducing nerv-audit (now on Maven Central): A Spring Boot audit framework powered by Hibernate Envers, with: - Clean architecture - Queryable audit history - Production-ready design If you're building serious systems, this is something you’ll eventually need. Full write-up here: https://lnkd.in/g2sv9dsM Curious how others are handling audit trails in their systems 👇 #SpringBoot #Java #SoftwareEngineering #Backend #OpenSource
Building a Robust Audit Logging System with nerv-audit for Spring Boot
More Relevant Posts
-
⚠️ Hot Reload in Spring Boot Isn’t Magic. It’s ClassLoader Isolation. When you change code and see: 👉 App restarts in seconds 👉 No full JVM restart What’s really happening? 1️⃣ Two ClassLoaders — The Core Idea Spring Boot DevTools splits your app into: Base ClassLoader → dependencies (stable) Restart ClassLoader → your application code (changing) 2️⃣ Why This Matters Dependencies (like Spring, Hibernate): Loaded once Heavy to reload Rarely change Your code: Changes frequently Needs fast reload So only your code is reloaded. 3️⃣ What Happens on Code Change You modify a .class file DevTools detects change (file watcher) Discards Restart ClassLoader Creates a new one Reloads your classes Base ClassLoader stays untouched 4️⃣ Why It’s Faster Than Full Restart Without DevTools: JVM restarts All classes reloaded Framework reinitialized With DevTools: Only your classes reload Dependencies reused Startup drastically reduced 5️⃣ What Actually Gets Restarted? Spring ApplicationContext Beans created again Config reloaded But: 👉 JVM process stays alive 👉 Core libraries remain loaded 6️⃣ Common Gotcha (Very Important) Static state survives in Base ClassLoader. Example: static Map cache = new HashMap(); If loaded by base loader: It won’t reset after reload Leads to weird bugs 7️⃣ Why Some Changes Don’t Reload DevTools won’t reload when: Dependency JAR changes Config outside classpath changes Native resources updated Requires full restart 8️⃣ Comparison With Other Tools Tool Approach DevTools ClassLoader restart JRebel Bytecode rewriting HotSwap Limited JVM replacement DevTools doesn’t “reload classes” It replaces the ClassLoader that loaded them #Java #SpringBoot #JVM #ClassLoader #HotReload #BackendEngineering #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
Top 5 Spring Boot mistakes that silently kill your app in production. 🚨 Everything works fine in dev… But in production, these small mistakes turn into major outages. If you’re a Spring Boot developer, double-check these 👇 ❌ 1️⃣ ddl-auto=update in Production 👉 Hibernate auto-modifies your database schema on startup ✋ Adds columns silently ✋ Never removes them ✋ One bad entity change = production table altered No rollback. No audit trail. No control. ✅ Fix: Use ddl-auto=none or validate in production. ⏱ 2️⃣ No Read Timeout on HTTP Clients 👉 Your service calls another service… and waits forever. ✋ Threads get blocked ✋ System slows down under load ✋ Eventually leads to cascading failures ✅ Fix: Always set ALL 3 timeouts Connection Timeout: 3s Read Timeout: 5s Connection Request Timeout: 2s ⚠️ 3️⃣ @Transactional on Private Methods 👉 This is silently ignored. ✋ No transaction created ✋ No rollback happens ✋ No warning or error Same applies to: ✋ @Async ✋ @Cacheable ✋ @Retryable Because Spring AOP works via proxies. 🔥 4️⃣ Returning Entities Directly from Controller 👉 Looks easy… but dangerous. ✋ Jackson calls getters → triggers lazy loading ✋ @OneToMany → loads 1000s of records silently ✋ Circular references → StackOverflowError ✅ Fix: Always return DTOs, not entities. 💥 5️⃣ Default HikariCP Pool + Long Transactions 👉 Default pool size = 10 connections Now imagine: ✋ @Transactional holds DB connection until method ends ✋ You call an external API inside transaction (5 seconds) ✋ 10 concurrent requests → pool exhausted 👉 Request #11 waits… 👉 Times out after 30 seconds Production slowdown starts here. 🧠 What’s the Pattern? 👉 These are not syntax errors. 👉 These are design mistakes. 👉 They don’t fail immediately… 👉 They fail under real production load. ⚡ Final Thought 👉 Good developers write working code. 👉 Great engineers write code that survives production. 👉 Which of these mistakes have you seen in real projects? 👇 #SpringBoot #Java #BackendDevelopment #Microservices #SoftwareEngineering #TechInterview #ProductionIssues #InterviewPrep #Softwaredeveloper
To view or add a comment, sign in
-
dmx-fun 0.0.14 Released! Version 0.0.14 is the ecosystem release. Where previous milestones built out the core type system, this one connects dmx-fun to the frameworks and infrastructure that production Java applications actually run on: Spring, Spring Boot, Micrometer, and Resilience4J. Five new production modules ship alongside new core types, collector façades, and a full Spring Boot reference application. Here is everything that changed: https://lnkd.in/ecRis2JM
To view or add a comment, sign in
-
🧬 Spring Boot – Understanding API Responses Today I explored how Spring Boot sends data from backend to frontend. 🧠 Key Learnings: ✔️ Returning a Java object automatically converts it to JSON ✔️ Spring Boot uses Jackson internally for this conversion ✔️ "@ResponseBody" ensures data is sent directly as response 💡 Best Practice: 👉 Using "@RestController" simplifies everything (Combination of @Controller + @ResponseBody) ✔️ Explored different return types: • Object • List • String • ResponseEntity (for better control over status & response) 🔁 API Flow: Request → Controller → Service → Return Object → JSON Response → Client 💻DSA Practice: • Even/Odd check using modulus • Sum of first N numbers (optimized using formula) ✨ Understanding how backend responses work is key to building real-world REST APIs. #SpringBoot #Java #BackendDevelopment #RESTAPI #WebDevelopment #DSA #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
The @Transactional Proxy Pitfall Think slapping @Transactional on a method guarantees database rollback on failure? Think again. 🚨 One of the most common critical bugs I see in Spring Boot applications isn't a logic error—it's a misunderstanding of how Spring AOP (Aspect-Oriented Programming) works under the hood. Enter the Self-Invocation Problem. If you have a non-transactional method processOrder() that calls a @Transactional method saveToDatabase() within the exact same class, that transaction will never start. If an exception is thrown, your data will not roll back. 💥 Why does this happen? Spring manages transactions using proxies. When an external class calls your bean, it hits the proxy first, which starts the transaction. But when you make an internal method call (calling this.saveToDatabase()), you are bypassing the proxy entirely and calling the raw object. No proxy = no transaction. How to fix it: 1️⃣ Refactor: Move the @Transactional method to a separate dedicated Service class (Best Practice). 2️⃣ Self-Injection: Inject the class into itself using @Autowired or constructor injection, and call the method via the injected instance. 3️⃣ AspectJ: Switch from proxy-based AOP to AspectJ weaving (Heavyweight, but solves proxy limitations). Understanding the framework's internal mechanics is the difference between writing code that compiles and writing systems that are truly fault-tolerant. Have you ever been bitten by the Spring proxy self-invocation trap? What is your favorite obscure Spring Boot "gotcha"? Let's geek out in the comments! 👇 Tags: #Java #SpringBoot #SoftwareEngineering #BackendDevelopment #AdvancedJava #SystemDesign #CodingTips
To view or add a comment, sign in
-
-
🚀 Spring Boot – User API Upgrade (Full CRUD) Took my mini project to the next level by implementing complete CRUD operations in Spring Boot. 🧠 What I added: ✔️ GET "/users" → Fetch all users ✔️ PUT "/user/{id}" → Update user ✔️ DELETE "/user/{id}" → Delete user 💡 Now the API supports full lifecycle operations: Create • Read • Update • Delete 🔁 Architecture in action: Controller → Service → In-memory data → JSON response 🧪 Tested all endpoints using Postman and verified the complete flow. ⚠️ Also understood the importance of proper error handling (next step: exception handling instead of returning null). 💻 DSA Practice: • Move zeros to end (array manipulation) • First non-repeating character (HashMap concept) ✨ This step helped me understand how real backend systems manage and manipulate data efficiently. #SpringBoot #Java #BackendDevelopment #RESTAPI #CRUD #DSA #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
In production Spring Boot services, scattered try-catch blocks create inconsistent API behavior. A better approach is centralized handling: ```@RestControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(ResourceNotFoundException.class) public ResponseEntity<ErrorResponse> handleNotFound(ResourceNotFoundException ex) { return ResponseEntity.status(HttpStatus.NOT_FOUND) .body(new ErrorResponse("RESOURCE_NOT_FOUND", ex.getMessage())); } @ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity<ErrorResponse> handleValidation(MethodArgumentNotValidException ex) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new ErrorResponse("VALIDATION_ERROR", "Invalid request payload")); } @ExceptionHandler(Exception.class) public ResponseEntity<ErrorResponse> handleGeneric(Exception ex) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("INTERNAL_ERROR", "Unexpected error occurred")); } }``` Benefits we observed: - Consistent contract for error payloads - Cleaner controllers/services - Accurate HTTP semantics (400, 404, 409, 500) - Better observability and incident response A strong error model is part of API design, not just exception handling. #SpringBoot #Java #Microservices #API #SoftwareEngineering #Backend
To view or add a comment, sign in
-
Is FetchType.EAGER silently killing your performance? 🚨 One mistake I’ve seen repeatedly in Spring Boot applications is overusing EAGER fetching. Looks harmless… until it hits production. The problem 👇 Every time you fetch a parent entity, Hibernate also loads the entire child collection. Now imagine: → A user with 5,000 orders → A department with 50,000 employees Your “simple query” just became a massive memory load. This doesn’t just slow things down… it stresses your entire JVM. What I follow instead 👇 ✔ Default to LAZY ✔ Use JOIN FETCH when needed ✔ Use @EntityGraph for controlled fetching Your entity design is not just structure. It’s a performance decision. Better to write 1 extra query… than load 10,000 unnecessary records. Curious to hear from other devs 👇 Do you treat FetchType.EAGER as a bad practice? Or still use it in some cases? #Java #SpringBoot #JPA #Hibernate #BackendDevelopment #SoftwareEngineering #Performance #TechDiscussion
To view or add a comment, sign in
-
-
When updating data in a Spring Boot API, standard validation can be too restrictive, often requiring all fields to be sent even for minor changes. A more flexible solution is to use @Validated with validation groups. This approach allows you to define separate sets of rules. For example, you can have a "create" group that requires all fields to be present, and a "default" group that only checks the format of fields that are actually provided in the request. In your controller, you then apply the appropriate rule set: the strict rules for creating new items and the flexible rules for updating them. This allows your API to handle both full and partial updates cleanly while reusing the same data object, resulting in more efficient code. #SpringBoot #Java #API #Validation #SoftwareDevelopment
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development