How to set up the Spring Boot Starter
What is the Spring Boot Starter
The Atoti What-If Spring Boot Starter provides auto-configuration for all What-If components. Instead of manually defining beans for the simulation engine, workflow, persistence, and security managers, the starter configures these automatically.
Benefits of using the starter:
- Minimal configuration required
- Sensible defaults for all components
- Easy customization through properties
- Ability to override any auto-configured bean
Prerequisites
- Java 21 or later
- Spring Boot 3.x
- Atoti Server 6.1.x
- Hibernate on the classpath (for JPA persistence)
How to add the dependency
<dependency>
<groupId>com.activeviam.apps</groupId>
<artifactId>atoti-what-if-spring-boot-starter</artifactId>
<version>5.0.0-AS6.1</version>
</dependency>
How to provide required beans
The starter requires two beans from your application:
IDatabaseService
The IDatabaseService is typically provided by your Atoti Server application. Most applications already have this bean configured.
IWhatIfPersistenceProperties
Provides Hibernate configuration for simulation persistence. This bean must return a Map<String, String> of Hibernate properties. The properties can be built in any way, such as from a properties file, environment variables, or hardcoded values.
Example using an inline map:
@Bean
public IWhatIfPersistenceProperties whatIfPersistenceProperties() {
return () -> Map.of(
"hibernate.hbm2ddl.auto", "update",
"hibernate.connection.url", "jdbc:h2:mem:submissions;DB_CLOSE_DELAY=-1",
"hibernate.connection.driver_class", "org.h2.Driver",
"hibernate.dialect", "org.hibernate.dialect.H2Dialect",
"hibernate.default_schema", "submissions"
);
}
Example loading from a properties file:
@Bean
public IWhatIfPersistenceProperties whatIfPersistenceProperties(
@Value("classpath:hibernate.properties") Resource resource) throws IOException {
Properties props = new Properties();
props.load(resource.getInputStream());
return () -> props.entrySet().stream()
.collect(Collectors.toMap(
e -> String.valueOf(e.getKey()),
e -> String.valueOf(e.getValue())
));
}
How to configure properties
Additional configuration is available through atoti.what-if.* properties in your application.yml or application.properties.
Enable/Disable What-If
All What-If features are enabled by default. To disable all What-If auto-configuration:
atoti:
what-if:
enable: false
Security configuration
atoti:
what-if:
security:
type: spring # spring, none, or custom
use-branch-permissions: true
Distributed mode configuration
atoti:
what-if:
distribution:
enabled: true
query-node-name: "query-node"
create-distributed-service: true
See the configuration reference for all available properties.
How to customize auto-configured beans
Any auto-configured bean can be overridden by providing your own bean of the same type. The starter uses @ConditionalOnMissingBean annotations, so your custom beans take precedence.
Example: Custom ID generator
@Bean
public IUniqueIdGenerator customIdGenerator() {
return new MyCustomIdGenerator();
}
Example: Custom security manager
@Bean
public IDatabaseSimulationsSecurityManager customSecurityManager(
ISimulationPersistenceManager persistenceManager) {
return new MyCustomSecurityManager(persistenceManager);
}
Next steps
- Implementation example for creating simulation definitions
- Components to understand the library structure
- Permissioning for security configuration details