Add .gitignore for Spring project files by JitenRajpurohit · Pull Request #4804 · github/gitignore
Reasons for making this change
Currently, the Java.gitignore provided in this repository focuses on core language artifacts but misses several critical files generated by the Spring Boot ecosystem and its integration with modern build tools (Maven/Gradle).
This new Spring.gitignore template provides:
- Build Tool Support: Specific ignores for Maven and Gradle wrappers and their temporary build directories (
target/,build/). - Spring Boot Specifics: Filtering out
.sts4-cache,.springBeans, and local configuration files (.env,*.properties.local) that often contain sensitive secrets. - IDE Integration: Support for Eclipse (STS), IntelliJ, and VS Code, which are the primary IDEs for Spring development.
Adding this as a standalone template allows developers to git init Spring projects with a "batteries-included" ignore file that prevents accidental commits of binary dependencies and local secrets.
Links to documentation supporting these rule changes
- Spring Boot Reference Guide: Executable Jar Layout (explains why
target/andbuild/must be ignored). - Spring Initializr (start.spring.io): The official Spring project generator includes a
.gitignoreby default; this PR aligns with the community standard set by the Spring team. - Baeldung - Guide to Gitignore for Java: Standard Java/Spring Ignore Patterns.