activiti7 springboot 多数据源配置
时间: 2023-05-13 22:04:32 浏览: 204
springboot配置多数据源
可以通过在 application.yml 文件中配置多个数据源来实现 activiti7 springboot 的多数据源配置。具体步骤如下:
1. 在 application.yml 文件中添加数据源配置,例如:
```
spring:
datasource:
primary:
url: jdbc:mysql://localhost:3306/activiti?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root
password: root
secondary:
url: jdbc:mysql://localhost:3306/activiti2?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root
password: root
```
2. 在启动类中添加数据源配置,例如:
```
@Configuration
public class DataSourceConfig {
@Bean(name = "primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.primary")
@Primary
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "secondaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.secondary")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
}
```
3. 在 activiti 配置文件中指定数据源,例如:
```
spring:
activiti:
database-schema-update: true
history-level: full
datasource:
primary: ${primaryDataSource}
secondary: ${secondaryDataSource}
```
这样就可以实现 activiti7 springboot 的多数据源配置了。
阅读全文