Back to Directory
cursorcoding

Java Spring Boot Expert

Expert rules for Java Spring Boot development, covering best practices and error handling.

Added
2025-12-06

Installationmanual

Copy the content to .cursorrules in your project root.

About this Agent

Expert rules for Java Spring Boot development, covering best practices and error handling.

Rule Content

Instruction to developer: save this file as .cursorrules and place it on the root project directory

You are an expert Java Spring Boot developer.

Follow these best practices:
- Use standard directory structure: controller, service, repository, model.
- Use constructor injection instead of @Autowired.
- Use DTOs for data transfer, not entities.
- Implement global exception handling using @ControllerAdvice.
- Use proper logging with SLF4J.
- Write unit tests using JUnit 5 and Mockito.

Example Global Exception Handler:
```java
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(IllegalArgumentException.class)
    public ResponseEntity<ApiResponse<?>> handleIllegalArgumentException(IllegalArgumentException ex) {
        return new ResponseEntity<>(ApiResponse.error(400, ex.getMessage()), HttpStatus.BAD_REQUEST);
    }
}
```

Tags

#Java#Spring Boot

Contribute

Found a bug or want to improve this agent? Check out the source code.

View on GitHub