Java · Kotlin · Spring Boot
Spring Boot rules for Cursor
Injection, configuration and testing rules for current Spring Boot services.
The rule
Save as .cursor/rules/spring-boot.mdc. Cursor picks it up on the next request.
.cursor/rules/spring-boot.mdc
--- description: Spring Boot service conventions globs: src/main/**/*.java, src/main/**/*.kt, src/test/**/*.java, src/test/**/*.kt, src/main/resources/application*.yml, src/main/resources/application*.properties alwaysApply: false --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
How Cursor loads this rule
Read from the frontmatter above, per Cursor's rules documentation.
alwaysApply: falsewithglobs: src/main/**/*.java, src/main/**/*.kt, src/test/**/*.java, src/test/**/*.kt, src/main/resources/application*.yml, src/main/resources/application*.properties: attached automatically when a matching file is in context.- Keep the
.mdcextension. A plain.mdfile in .cursor/rules is ignored by the rules system. - Prefer to generate your own? Type
/create-rulein Agent and describe what you want; Cursor saves the file to .cursor/rules. - Team Rules come first, then Project Rules like this one, then User Rules. Earlier sources win when guidance conflicts.
Cursor rules setup guideCursor Team RulesLet Cursor run commands without asking
Spring Boot rules for Claude Code, Copilot, Kiro and other agents
The same instructions work as plain Markdown in AGENTS.md, which Codex, Gemini CLI, GitHub Copilot and most other coding agents read.
AGENTS.md (section)
## Spring Boot - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Claude Code.claude/rules/spring-boot.md
.claude/rules/spring-boot.md
--- paths: - "src/main/**/*.java" - "src/main/**/*.kt" - "src/test/**/*.java" - "src/test/**/*.kt" - "src/main/resources/application*.yml" - "src/main/resources/application*.properties" --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for GitHub Copilot.github/instructions/spring-boot.instructions.md
.github/instructions/spring-boot.instructions.md
--- applyTo: "src/main/**/*.java,src/main/**/*.kt,src/test/**/*.java,src/test/**/*.kt,src/main/resources/application*.yml,src/main/resources/application*.properties" --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Kiro.kiro/steering/spring-boot.md
.kiro/steering/spring-boot.md
--- inclusion: fileMatch fileMatchPattern: ["src/main/**/*.java", "src/main/**/*.kt", "src/test/**/*.java", "src/test/**/*.kt", "src/main/resources/application*.yml", "src/main/resources/application*.properties"] --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Antigravity.agents/rules/spring-boot.md
.agents/rules/spring-boot.md
--- trigger: glob globs: "src/main/**/*.java, src/main/**/*.kt, src/test/**/*.java, src/test/**/*.kt, src/main/resources/application*.yml, src/main/resources/application*.properties" --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Devin Desktop (Windsurf).devin/rules/spring-boot.md
.devin/rules/spring-boot.md
--- trigger: glob globs: src/main/**/*.java, src/main/**/*.kt, src/test/**/*.java, src/test/**/*.kt, src/main/resources/application*.yml, src/main/resources/application*.properties --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Cline.clinerules/spring-boot.md
.clinerules/spring-boot.md
--- paths: - "src/main/**/*.java" - "src/main/**/*.kt" - "src/test/**/*.java" - "src/test/**/*.kt" - "src/main/resources/application*.yml" - "src/main/resources/application*.properties" --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
Spring Boot rules for Continue.continue/rules/spring-boot.md
.continue/rules/spring-boot.md
--- name: "spring-boot" globs: ["src/main/**/*.java", "src/main/**/*.kt", "src/test/**/*.java", "src/test/**/*.kt", "src/main/resources/application*.yml", "src/main/resources/application*.properties"] --- - Use constructor injection with final fields; no @Autowired on fields. - Bind configuration to @ConfigurationProperties classes or records instead of scattering @Value. - Use jakarta.* imports, never javax.* for servlet, validation or persistence APIs. - Use records for request and response DTOs; never return JPA entities from controllers. - Validate request bodies with @Valid and Bean Validation annotations. - Handle errors in a @RestControllerAdvice that returns ProblemDetail responses. - Put @Transactional on service methods, not controllers or repositories. - Use RestClient for outgoing HTTP calls instead of RestTemplate. - In tests, use @MockitoBean (not @MockBean), slice tests such as @WebMvcTest or @DataJpaTest, and Testcontainers for real databases.
More templates
Get Cursor rules and settings changes by email
When Cursor changes how rules, run modes or settings work, we update these templates from the docs and send a short note. One email a week at most.
Reviewed Oct 20, 2026. Written by AgentAtlas. Adapt it to your codebase before relying on it.