Why Your Java Projects Keep Failing and How to Fix Common Spring Boot Pitfalls
The article examines recurring Java backend problems such as duplicated configuration files, hard‑coded parameters, mixed logging practices, unchecked code releases, unsynchronized databases, and Maven dependency issues, then offers concrete solutions like externalized configuration, standardized logging, proper code review, and correct Maven pom settings.
Opening the Code Reveals Continuous Issues
1. The project reads two configuration files—one internal and one external—causing confusion; mixing them leads to messy setups. prop_c.setProperty(key, value); When the external configuration is missing, a NullPointerException is thrown because the underlying collection is a Hashtable.
public synchronized V put(K key, V value) {
// Make sure the value is not null
if (value == null) {
throw new NullPointerException();
}
}2. Many parameters are hard‑coded in the code, making future changes labor‑intensive (e.g., role checks). role.haveRole("ADMIN_USE") 3. Logging mixes System.out.println and proper logger calls, and stack traces are often omitted.
4. Code is deployed to production without technical manager review, leading to inconsistencies between production and local environments, especially unsynchronized database data.
5. Arbitrary changes to the production database rely solely on developers' professionalism.
6. Maven dependencies reference a pom without generating a usable JAR; adding <type>pom</type> can resolve the issue, though the purpose is unclear.
How to Solve These Problems
For new or upgraded projects, place all configuration in application.xml/yml for the development environment and avoid external files; for production, specify the configuration location via startup scripts, e.g.:
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=server/src/main/config/application.properties -jar xxx.jar &Adopt dynamic configuration when needed, follow coding standards, avoid unnecessary source changes, and rely on proper logging (use a logger instead of System.out). Ensure code reviews before production release and keep database schemas synchronized. Adjust Maven pom files by adding the correct <type>pom</type> element.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
