Installation & Setup
Requirements
Section titled “Requirements”- Java 17+ Required by both rulii and Spring Boot 4.x.
- Spring Boot 4.1+ Uses Spring Framework 7.0 and the
@AutoConfigurationmechanism. - rulii 2.3.0 The core rule engine. Pulled in transitively.
Add rulii-spring to your pom.xml. It transitively brings in the core rulii library, so you don’t need to declare it separately.
<dependency> <groupId>org.rulii</groupId> <artifactId>rulii-spring</artifactId> <version>2.3.0</version></dependency>Bean Validation on rulii is opt-in: add rulii-bean-validation beside it and the application’s Validator runs on rulii in place of Hibernate Validator. Bean Validation below says how.
You also need Spring Boot’s autoconfigure starter on the classpath (typically already present in any Spring Boot project):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId></dependency>Gradle
Section titled “Gradle”implementation 'org.rulii:rulii-spring:2.3.0'implementation 'org.springframework.boot:spring-boot-starter'Minimal Application
Section titled “Minimal Application”Once the dependency is on the classpath, Spring Boot auto-configures the rule engine. Add @RuleScan to tell it where your rules live:
import org.rulii.spring.annotation.RuleScan;
@SpringBootApplication@RuleScan(scanBasePackages = "com.example.rules")public class Application {
public static void main(String[] args) { SpringApplication.run(Application.class, args); }}That’s it. On startup, rulii-spring will scan the specified packages for classes annotated with @Rule, register them as Spring beans, and wire up all nine core beans (covered in the next section).
Bean Validation
Section titled “Bean Validation”Bean Validation on rulii is opt-in. Add org.rulii:rulii-bean-validation beside rulii-spring and, with Spring Boot’s validation module on the classpath (what spring-boot-starter-validation brings), the application’s Validator bean becomes the rulii provider, in place of Hibernate Validator and even when Hibernate Validator is still on the classpath: your jakarta.validation constraints run as rulii rules, and @Validate names resolve to Spring beans. Adding the dependency is the switch; nothing else needs to be declared.
<dependency> <groupId>org.rulii</groupId> <artifactId>rulii-bean-validation</artifactId> <version>1.1.0</version></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId></dependency>Without the dependency rulii-spring leaves Bean Validation alone, and the application validates as Spring Boot sets it up.
Version Compatibility Matrix
Section titled “Version Compatibility Matrix”| rulii-spring | rulii | Spring Boot | Java |
|---|---|---|---|
| 2.3.0 | 2.3.0 | 4.1+ | 17+ |
| 2.2.0 | 2.2.0 | 4.1+ | 17+ |
| 2.1.0 | 2.1.0 | 4.1+ | 17+ |
| 2.0.0 | 2.0.0 | 3.5+ | 17+ |
| 1.2.0 | 1.2.0 | 3.4+ | 17+ |