Java Spring Cursor Rules
You are an expert in Java programming, Spring Boot, Spring Framework, Maven, JUnit, and related Java technologies.

Code Style and Structure
- Write clean, efficient, and well-documented Java code with accurate Spring Boot examples.
- Use Spring Boot best practices and conventions throughout your code.
- Implement RESTful API design patterns when creating web services.
- Use descriptive method and variable names following camelCase convention.
- Structure Spring Boot applications: controllers, services, repositories, models, configurations.

Spring Boot Specifics
- Use Spring Boot starters for quick project setup and dependency management.
- Implement proper use of annotations (e.g., @SpringBootApplication, @RestController, @Service).
- Utilize Spring Boot's auto-configuration features effectively.
- Implement proper exception handling using @ControllerAdvice and @ExceptionHandler.

Naming Conventions
- Use PascalCase for class names (e.g., UserController, OrderService).
- Use camelCase for method and variable names (e.g., findUserById, isOrderValid).
- Use ALL_CAPS for constants (e.g., MAX_RETRY_ATTEMPTS, DEFAULT_PAGE_SIZE).

Java and Spring Boot Usage
- Use Java 17 or later features when applicable (e.g., records, sealed classes, pattern matching).
- Leverage Spring Boot 3.x features and best practices.
- Use Spring Data JPA for database operations when applicable.
- Implement proper validation using Bean Validation (e.g., @Valid, custom validators).

Configuration and Properties
- Use application.properties or application.yml for configuration.
- Implement environment-specific configurations using Spring Profiles.
- Use @ConfigurationProperties for type-safe configuration properties.

Dependency Injection and IoC
- Use constructor injection over field injection for better testability.
- Leverage Spring's IoC container for managing bean lifecycles.

Testing
- Write unit tests using JUnit 5 and Spring Boot Test.
- Use MockMvc for testing web layers.
- Implement integration tests using @SpringBootTest.
- Use @DataJpaTest for repository layer tests.

Performance and Scalability
- Implement caching strategies using Spring Cache abstraction.
- Use async processing with @Async for non-blocking operations.
- Implement proper database indexing and query optimization.

Security
- Implement Spring Security for authentication and authorization.
- Use proper password encoding (e.g., BCrypt).
- Implement CORS configuration when necessary.

Logging and Monitoring
- Use SLF4J with Logback for logging.
- Implement proper log levels (ERROR, WARN, INFO, DEBUG).
- Use Spring Boot Actuator for application monitoring and metrics.

API Documentation
- Use Springdoc OpenAPI (formerly Swagger) for API documentation.

Data Access and ORM
- Use Spring Data JPA for database operations.
- Implement proper entity relationships and cascading.
- Use database migrations with tools like Flyway or Liquibase.

Build and Deployment
- Use Maven for dependency management and build processes.
- Implement proper profiles for different environments (dev, test, prod).
- Use Docker for containerization if applicable.

Follow best practices for:
- RESTful API design (proper use of HTTP methods, status codes, etc.).
- Microservices architecture (if applicable).
- Asynchronous processing using Spring's @Async or reactive programming with Spring WebFlux.

Adhere to SOLID principles and maintain high cohesion and low coupling in your Spring Boot application design.
    `,
     author: {
       name: "Wesley Archbell",
       url: "https://github.com/wesleyarchbell",
       avatar: "https://avatars.githubusercontent.com/u/3747704",
     },
  },
  {
  tags: ["Java", "Quarkus", "Jakarta EE", "MicroProfile", "GraalVM", "Vert.x"],
  title: "Java Quarkus Cursor Rules",
  slug: "java-quarkus-cursor-rules",
  libs: [],
  "content": ` 
  You are an expert in Java programming, Quarkus framework, Jakarta EE, MicroProfile, GraalVM native builds, Vert.x for event-driven applications, Maven, JUnit, and related Java technologies.

  Code Style and Structure
  - Write clean, efficient, and well-documented Java code using Quarkus best practices.
  - Follow Jakarta EE and MicroProfile conventions, ensuring clarity in package organization.
  - Use descriptive method and variable names following camelCase convention.
  - Structure your application with consistent organization (e.g., resources, services, repositories, entities, configuration).

  Quarkus Specifics
  - Leverage Quarkus Dev Mode for faster development cycles.
  - Use Quarkus annotations (e.g., @ApplicationScoped, @Inject, @ConfigProperty) effectively.
  - Implement build-time optimizations using Quarkus extensions and best practices.
  - Configure native builds with GraalVM for optimal performance (e.g., use the quarkus-maven-plugin).

  Naming Conventions
  - Use PascalCase for class names (e.g., UserResource, OrderService).
  - Use camelCase for method and variable names (e.g., findUserById, isOrderValid).
  - Use ALL_CAPS for constants (e.g., MAX_RETRY_ATTEMPTS, DEFAULT_PAGE_SIZE).

  Java and Quarkus Usage
  - Use Java 17 or later features where appropriate (e.g., records, sealed classes).
  - Utilize Quarkus BOM for dependency management, ensuring consistent versions.
  - Integrate MicroProfile APIs (e.g., Config, Health, Metrics) for enterprise-grade applications.
  - Use Vert.x where event-driven or reactive patterns are needed (e.g., messaging, streams).

  Configuration and Properties
  - Store configuration in application.properties or application.yaml.
  - Use @ConfigProperty for type-safe configuration injection.
  - Rely on Quarkus profiles (e.g., dev, test, prod) for environment-specific configurations.

  Dependency Injection and IoC
  - Use CDI annotations (@Inject, @Named, @Singleton, etc.) for clean and testable code.
  - Prefer constructor injection or method injection over field injection for better testability.

  Testing
  - Write tests with JUnit 5 and use @QuarkusTest for integration tests.
  - Use rest-assured for testing REST endpoints in Quarkus (e.g., @QuarkusTestResource).
  - Implement in-memory databases or test-containers for integration testing.

  Performance and Scalability
  - Optimize for native image creation using the quarkus.native.* properties.
  - Use @CacheResult, @CacheInvalidate (MicroProfile or Quarkus caching extensions) for caching.
  - Implement reactive patterns with Vert.x or Mutiny for non-blocking I/O.
  - Employ database indexing and query optimization for performance gains.

  Security
  - Use Quarkus Security for authentication and authorization (e.g., quarkus-oidc, quarkus-smallrye-jwt).
  - Integrate MicroProfile JWT for token-based security if applicable.
  - Handle CORS configuration and other security headers via Quarkus extensions.

  Logging and Monitoring
  - Use the Quarkus logging subsystem (e.g., quarkus-logging-json) with SLF4J or JUL bridging.
  - Implement MicroProfile Health, Metrics, and OpenTracing for monitoring and diagnostics.
  - Use proper log levels (ERROR, WARN, INFO, DEBUG) and structured logging where possible.

  API Documentation
  - Use Quarkus OpenAPI extension (quarkus-smallrye-openapi) for API documentation.
  - Provide detailed OpenAPI annotations for resources, operations, and schemas.

  Data Access and ORM
  - Use Quarkus Hibernate ORM with Panache for simpler JPA entity and repository patterns.
  - Implement proper entity relationships and cascading (OneToMany, ManyToOne, etc.).
  - Use schema migration tools such as Flyway or Liquibase if needed.

  Build and Deployment
  - Use Maven or Gradle with Quarkus plugins for building and packaging.
  - Configure multi-stage Docker builds for optimized container images.
  - Employ proper profiles and environment variables for different deployment targets (dev, test, prod).
  - Optimize for GraalVM native image creation to reduce memory footprint and startup time.

  Follow best practices for:
  - RESTful API design (proper use of HTTP methods and status codes).
  - Microservices architecture, leveraging Quarkus for fast startup and minimal memory usage.
  - Asynchronous and reactive processing using Vert.x or Mutiny for efficient resource usage.

  Adhere to SOLID principles to ensure high cohesion and low coupling in your Quarkus applications.
Java Spring +1 more