Browse Source
Merge branch 'milestone-20251016-现金管理' of http://39.101.133.168:8807/huangqizhen/gold-java into lijianlin/feature-202509231533026-现金管理-收款管理
lijianlin/feature-202509231533026-现金管理-收款管理
Merge branch 'milestone-20251016-现金管理' of http://39.101.133.168:8807/huangqizhen/gold-java into lijianlin/feature-202509231533026-现金管理-收款管理
lijianlin/feature-202509231533026-现金管理-收款管理
6 changed files with 121 additions and 4 deletions
-
5pom.xml
-
6src/main/java/com/example/demo/DemoApplication.java
-
34src/main/java/com/example/demo/config/FlowableDataSourceConfig.java
-
56src/main/java/com/example/demo/config/work/FlowableEngineConfig.java
-
9src/main/resources/application-dev.yml
-
13src/main/resources/application-test.yml
@ -0,0 +1,34 @@ |
|||
// FlowableDataSourceConfig.java |
|||
package com.example.demo.config; |
|||
|
|||
import com.zaxxer.hikari.HikariDataSource; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.boot.jdbc.DataSourceBuilder; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|||
import org.springframework.transaction.PlatformTransactionManager; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Configuration |
|||
public class FlowableDataSourceConfig { |
|||
|
|||
@Bean(name = "flowableDataSource") |
|||
@ConfigurationProperties(prefix = "spring.datasource.flowable") |
|||
public DataSource flowableDataSource() { |
|||
HikariDataSource ds = DataSourceBuilder |
|||
.create() |
|||
.type(HikariDataSource.class) |
|||
.build(); |
|||
ds.setConnectionInitSql("SET SESSION sql_mode='TRADITIONAL';"); |
|||
return ds; |
|||
} |
|||
|
|||
@Bean(name = "flowableTransactionManager") |
|||
public PlatformTransactionManager flowableTransactionManager( |
|||
@Qualifier("flowableDataSource") DataSource dataSource) { |
|||
return new DataSourceTransactionManager(dataSource); |
|||
} |
|||
} |
@ -0,0 +1,56 @@ |
|||
// FlowableEngineConfig.java |
|||
package com.example.demo.config.work; |
|||
|
|||
import org.flowable.common.engine.impl.history.HistoryLevel; |
|||
import org.flowable.engine.HistoryService; |
|||
import org.flowable.engine.RepositoryService; |
|||
import org.flowable.engine.RuntimeService; |
|||
import org.flowable.engine.TaskService; |
|||
|
|||
import org.flowable.spring.SpringProcessEngineConfiguration; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.transaction.PlatformTransactionManager; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Configuration |
|||
public class FlowableEngineConfig { |
|||
|
|||
@Bean |
|||
public SpringProcessEngineConfiguration processEngineConfiguration( |
|||
@Qualifier("flowableDataSource") DataSource flowableDataSource, |
|||
@Qualifier("flowableTransactionManager") PlatformTransactionManager transactionManager) { |
|||
|
|||
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration(); |
|||
config.setDataSource(flowableDataSource); // 👈 指定 Flowable 数据源 |
|||
config.setTransactionManager(transactionManager); |
|||
config.setDatabaseSchemaUpdate("true"); // 自动建表 |
|||
config.setHistoryLevel(HistoryLevel.FULL).setAsyncExecutorActivate(false); // 记录完整历史 |
|||
// 暂时关闭异步执行器 |
|||
|
|||
return config; |
|||
} |
|||
|
|||
// 👇 以下 Service Bean 可选,但推荐注入,方便 Controller 使用 |
|||
@Bean |
|||
public RepositoryService repositoryService(SpringProcessEngineConfiguration config) { |
|||
return config.buildProcessEngine().getRepositoryService(); |
|||
} |
|||
|
|||
@Bean |
|||
public RuntimeService runtimeService(SpringProcessEngineConfiguration config) { |
|||
return config.buildProcessEngine().getRuntimeService(); |
|||
} |
|||
|
|||
@Bean |
|||
public TaskService taskService(SpringProcessEngineConfiguration config) { |
|||
return config.buildProcessEngine().getTaskService(); |
|||
} |
|||
|
|||
@Bean |
|||
public HistoryService historyService(SpringProcessEngineConfiguration config) { |
|||
return config.buildProcessEngine().getHistoryService(); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue