Flowable 配置单独数据库
Flowable Spring Boot About 1,777 words环境
Spring Boot 3
、Flowable 7
。
代码
yaml 配置
flowable:
datasource:
url: jdbc:postgresql://localhost:5432/flowable
driver-class-name: org.postgresql.Driver
username: postgres
password: 123456
数据源配置
实现EngineConfigurator
。
@Component
public class DatasourceConfigurator implements EngineConfigurator {
@Value("${flowable.datasource.url}")
private String url;
@Value("${flowable.datasource.driver-class-name}")
private String driverClassName;
@Value("${flowable.datasource.username}")
private String username;
@Value("${flowable.datasource.password}")
private String password;
@Override
public void beforeInit(AbstractEngineConfiguration engineConfiguration) {
DataSource dataSource = DataSourceBuilder.create()
.driverClassName(driverClassName)
.url(url)
.username(username)
.password(password).build();
engineConfiguration.setDataSource(dataSource);
}
@Override
public void configure(AbstractEngineConfiguration engineConfiguration) {
}
@Override
public int getPriority() {
return 100000;
}
}
实现EngineConfigurationConfigurer
,泛型为SpringProcessEngineConfiguration
。
@Configuration
public class ProcessEngineConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
private DatasourceConfigurator datasourceConfigurator;
@Autowired
public void setDatasourceConfigurator(DatasourceConfigurator datasourceConfigurator) {
this.datasourceConfigurator = datasourceConfigurator;
}
@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
engineConfiguration.addConfigurator(datasourceConfigurator);
}
}
Views: 587 · Posted: 2024-03-11
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...