Java Companion
Author

Java Companion

A highly professional Java public account

99
Articles
0
Likes
103
Views
0
Comments
Recent Articles

Latest from Java Companion

99 recent articles
Java Companion
Java Companion
Feb 22, 2026 · Backend Development

Why Most Backend Architecture Patterns Are Over‑engineered

A recent code review reveals a colleague using strategy, factory, and abstract‑factory patterns to build a payment system that only needs two methods, exposing how 90 % of classic backend architecture patterns become unnecessary over‑design in modern microservice and cloud‑native environments, and offering practical guidelines for when such complexity truly adds value.

Code ReviewDesign PatternsMicroservices
0 likes · 13 min read
Why Most Backend Architecture Patterns Are Over‑engineered
Java Companion
Java Companion
Feb 21, 2026 · Backend Development

Build Your Own Spring Boot API Guard: Anti‑Duplicate Submissions and Rate Limiting

The article introduces Guardian, a lightweight Spring Boot starter that provides independent anti‑duplicate‑submission and rate‑limiting modules, explains why a custom solution is preferable to raw Redis locks, and walks through annotation and YAML configurations, key generation, response handling, storage options, concurrency safety, and observability.

API GuardAnti-duplicate SubmissionRate Limiting
0 likes · 17 min read
Build Your Own Spring Boot API Guard: Anti‑Duplicate Submissions and Rate Limiting
Java Companion
Java Companion
Feb 10, 2026 · Backend Development

Why Successful Payments Vanished: MyBatis Connection‑Pool Pitfalls Explained

A production incident where payment orders appeared successful but were not persisted was traced to a missing commit in a special‑case branch, causing a polluted connection to be reused by Spring's transaction manager, leading to intermittent failures that were resolved by fixing the commit logic and adding connection‑pool health checks.

Connection PoolDatabase MonitoringDebugging
0 likes · 10 min read
Why Successful Payments Vanished: MyBatis Connection‑Pool Pitfalls Explained
Java Companion
Java Companion
Feb 7, 2026 · Backend Development

Why Should the Service Layer in Java Not Return a Result Object Directly?

The article explains that returning a Result wrapper from the Service layer mixes business logic with presentation concerns, leading to tighter coupling, reduced reusability, cumbersome error handling, harder testing, poorer DDD alignment, limited interface flexibility, and ambiguous transaction boundaries.

Domain-Driven DesignException HandlingJava
0 likes · 11 min read
Why Should the Service Layer in Java Not Return a Result Object Directly?
Java Companion
Java Companion
Feb 5, 2026 · Backend Development

Elegant Dynamic Data Source Switching in SpringBoot Using ThreadLocal and AbstractRoutingDataSource

This article walks through building an elegant dynamic data‑source switch in SpringBoot by combining ThreadLocal with AbstractRoutingDataSource, covering the context holder, custom routing class, YAML configuration, testing, annotation‑driven switching, and runtime addition of new data sources.

AOPMybatis-PlusRuntime DataSource Registration
0 likes · 16 min read
Elegant Dynamic Data Source Switching in SpringBoot Using ThreadLocal and AbstractRoutingDataSource
Java Companion
Java Companion
Feb 3, 2026 · Backend Development

Build Standalone Installers for Spring Boot Apps with JPackage

This guide walks through using JPackage (standard from JDK 16) to create native Windows, macOS, and Linux installers for Spring Boot applications, covering JDK requirements, platform‑specific tools, custom JRE creation with jlink, Maven integration, and step‑by‑step command examples.

JLinkLinuxMaven
0 likes · 12 min read
Build Standalone Installers for Spring Boot Apps with JPackage
Java Companion
Java Companion
Feb 1, 2026 · Databases

How I Completed a 100+ Table Migration in One Month Using Navicat Tricks

In under a month the author migrated more than 100 heterogeneous tables from MySQL and MongoDB to PostgreSQL across isolated networks by automating Navicat's import/export logic, streaming data, handling special characters, configuring flexible sync strategies, and using OSS as a bridge to avoid OOM and lock‑contention.

Data MigrationMongoDBNavicat
0 likes · 20 min read
How I Completed a 100+ Table Migration in One Month Using Navicat Tricks
Java Companion
Java Companion
Jan 30, 2026 · Backend Development

When @Transactional and TransactionTemplate Clash: How to Choose the Right Spring Transaction Management

This article examines Spring's three transaction management options—@Transactional, TransactionTemplate, and TransactionManager—explaining their mechanisms, common pitfalls such as internal method calls and timeout settings, and provides guidance on when to use each approach with concrete code examples.

TransactionManagerbackendspring
0 likes · 12 min read
When @Transactional and TransactionTemplate Clash: How to Choose the Right Spring Transaction Management
Java Companion
Java Companion
Jan 29, 2026 · Backend Development

How to Cut MyBatis Batch Insert Time from 5 Minutes to 3 Seconds: Three Key Optimizations

The article walks through turning a naïve MyBatis loop that took five minutes to insert 100,000 rows into a high‑performance solution that finishes in three seconds by applying batch SQL, JDBC batch mode with rewriteBatchedStatements, and multithreaded parallel execution, while highlighting pitfalls and best‑practice configurations.

Batch InsertExecutorType.BATCHJDBC
0 likes · 9 min read
How to Cut MyBatis Batch Insert Time from 5 Minutes to 3 Seconds: Three Key Optimizations
Java Companion
Java Companion
Jan 23, 2026 · Backend Development

Maven 4 Officially Announced: A 15‑Year Overhaul of Java’s Build Tool

Maven 4, now in its fifth release candidate, modernizes the 15‑year‑old Java build ecosystem with a new POM model, native Build/Consumer POM separation, explicit artifact types, subproject renaming, tree‑based lifecycle for parallel builds, and richer configuration options, while providing an official upgrade assistant.

Artifact TypesBuild ToolJava
0 likes · 9 min read
Maven 4 Officially Announced: A 15‑Year Overhaul of Java’s Build Tool