Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
activiti_tutorial
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 1328bbc5
authored
2018-03-28 14:27:25 +0800
by
ethanlamzs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
暂时可以 实现 activiti 与 spring boot的集成 -- beta 状态
1 parent
753d4d10
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
4 deletions
pom.xml
src/main/java/com/qtone/wx/activititutorial/ActivitiTutorialApplication.java
src/main/java/com/qtone/wx/activititutorial/MyService.java
src/main/resources/_.yaml
src/main/resources/application.properties
src/main/resources/processes/VacationRequest.bpmn20.xml
pom.xml
View file @
1328bbc
...
...
@@ -14,7 +14,7 @@
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.0.0
.RELEASE
</version>
<version>
1.5.6
.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
...
...
@@ -22,6 +22,8 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<activiti.version>
6.0.0
</activiti.version>
<mysql.version>
5.1.46
</mysql.version>
</properties>
<dependencies>
...
...
@@ -35,6 +37,26 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.activiti
</groupId>
<artifactId>
activiti-spring-boot-starter-basic
</artifactId>
<version>
${activiti.version}
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
${mysql.version}
</version>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.apache.tomcat
</groupId>
<artifactId>
tomcat-jdbc
</artifactId>
<version>
8.0.15
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/qtone/wx/activititutorial/ActivitiTutorialApplication.java
View file @
1328bbc
...
...
@@ -2,13 +2,25 @@ package com.qtone.wx.activititutorial;
import
java.util.Arrays
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.TaskService
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
javax.sql.DataSource
;
@SpringBootApplication
@Configuration
@ComponentScan
@EnableAutoConfiguration
public
class
ActivitiTutorialApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -16,6 +28,7 @@ public class ActivitiTutorialApplication {
}
@Bean
public
CommandLineRunner
commandLineRunner
(
ApplicationContext
ctx
)
{
return
args
->
{
...
...
@@ -30,4 +43,35 @@ public class ActivitiTutorialApplication {
};
}
@Bean
public
CommandLineRunner
init
(
final
RepositoryService
repositoryService
,
final
RuntimeService
runtimeService
,
final
TaskService
taskService
)
{
return
new
CommandLineRunner
()
{
@Override
public
void
run
(
String
...
strings
)
throws
Exception
{
System
.
out
.
println
(
"Number of process definitions : "
+
repositoryService
.
createProcessDefinitionQuery
().
count
());
System
.
out
.
println
(
"Number of tasks : "
+
taskService
.
createTaskQuery
().
count
());
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
);
System
.
out
.
println
(
"Number of tasks after process start: "
+
taskService
.
createTaskQuery
().
count
());
}
};
}
@Bean
public
DataSource
database
()
{
return
DataSourceBuilder
.
create
()
.
url
(
"jdbc:mysql://115.28.171.4:3306/spring-boot-activiti?characterEncoding=UTF-8"
)
.
username
(
"root"
)
.
password
(
"123456"
)
.
driverClassName
(
"com.mysql.jdbc.Driver"
)
.
build
();
}
}
src/main/java/com/qtone/wx/activititutorial/MyService.java
0 → 100644
View file @
1328bbc
package
com
.
qtone
.
wx
.
activititutorial
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.TaskService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
public
class
MyService
{
@Autowired
private
RuntimeService
runtimeService
;
@Autowired
private
TaskService
taskService
;
@Transactional
public
void
startProcess
()
{
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
);
}
}
\ No newline at end of file
src/main/resources/_.yaml
0 → 100644
View file @
1328bbc
File mode changed
src/main/resources/application.properties
View file @
1328bbc
spring.datasource.url
=
jdbc:mysql://115.28.171.4:3306/spring-boot-activiti?characterEncoding=utf8&useSSL=true
spring.datasource.username
=
root
spring.datasource.password
=
123456
spring.datasource.driver-class-
name
=
com.mysql.jdbc.Driver
#自动创建、更新、验证数据库表结构
spring.jpa.properties.hibernate.hbm2ddl.auto
=
update
spring.jpa.show-
sql
=
true
src/main/resources/processes/VacationRequest.bpmn20.xml
0 → 100644
View file @
1328bbc
<?xml version="1.0" encoding="UTF-8" ?>
<definitions
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"Examples"
>
<process
id=
"oneTaskProcess"
name=
"The One Task Process"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theTask"
/>
<userTask
id=
"theTask"
name=
"my task"
/>
<sequenceFlow
id=
"flow2"
sourceRef=
"theTask"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment