本项目采用ssm+maven构建。
1.准备资源文件 activti-5.22.zip源码
http://download.csdn.net/download/duguxingfeng/10150341
2.工程目录结构
2.源码解压复制文件
2.1将Activiti-activiti-5.22.0\modules\activiti-modeler中的源码复制到工程目录controller下
copy的文件分别为:
1.StencilsetRestResource.java
2.ModelEditorJsonRestResource.java
3.ModelSaveRestResource.java
2.2将Activiti-activiti-5.22.0\modules\activiti-webapp-explorer2\src\main\webapp里面的
1.diagram-viewer
2.editor-app
3.modeler.html
复制到工程的webapp目录下
2.3将Activiti-activiti-5.22.0\modules\activiti-webapp-explorer2\src\main\resources里面的
stencilset.json
复制到工程的resource目录下
3.pom.xml
4.0.0
com.cesat
activiti_modeler
war
0.0.1-SNAPSHOT
zjzb_qc Maven Webapp
http://maven.apache.org
4.3.8.RELEASE
3.2.6
1.7.25
1.2.17
5.22.0
junit
junit
4.12
org.hamcrest
hamcrest-all
1.3
test
org.apache.shiro
shiro-core
1.2.3
org.apache.shiro
shiro-web
1.2.3
org.apache.shiro
shiro-ehcache
1.2.3
org.apache.shiro
shiro-spring
1.2.3
org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-oxm
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-aop
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-test
${spring.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
javax
javaee-api
7.0
c3p0
c3p0
0.9.1.2
com.jolbox
bonecp
0.8.0.RELEASE
mysql
mysql-connector-java
5.1.30
commons-dbcp
commons-dbcp
1.2.2
jstl
jstl
1.2
log4j
log4j
${log4j.version}
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
org.codehaus.jackson
jackson-mapper-asl
1.9.13
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.4
commons-codec
commons-codec
1.9
javax.servlet
javax.servlet-api
3.1.0
javax.servlet.jsp
javax.servlet.jsp-api
2.3.1
javax.servlet
jstl
1.2
org.json
json
20170516
com.github.pagehelper
pagehelper
4.1.6
joda-time
joda-time
2.3
com.fasterxml.jackson.core
jackson-databind
2.8.9
javax.activation
activation
1.1.1
org.activiti
activiti-bpmn-converter
${activiti.version}
org.activiti
activiti-bpmn-layout
${activiti.version}
org.activiti
activiti-diagram-rest
${activiti.version}
org.activiti
activiti-bpmn-model
${activiti.version}
org.activiti
activiti-engine
${activiti.version}
org.activiti
activiti-image-generator
${activiti.version}
org.activiti
activiti-json-converter
${activiti.version}
commons-collections
commons-collections
org.activiti
activiti-process-validation
${activiti.version}
org.activiti
activiti-spring
${activiti.version}
commons-dbcp
commons-dbcp
batik
batik-anim
1.7
org.apache.xmlgraphics
batik-awt-util
1.7
org.apache.xmlgraphics
batik-bridge
1.7
org.apache.xmlgraphics
batik-codec
1.7
org.apache.xmlgraphics
batik-css
1.7
org.apache.xmlgraphics
batik-dom
1.7
org.apache.xmlgraphics
batik-ext
1.7
batik
batik-gvt
1.7
org.apache.xmlgraphics
batik-js
1.7
org.apache.xmlgraphics
batik-parser
1.7
batik
batik-script
1.7
batik
batik-svg-dom
1.7
batik
batik-svggen
1.7
batik
batik-transcoder
1.7
batik
batik-util
1.7
batik
batik-xml
1.7
org.apache.commons
commons-lang3
3.3.2
joda-time
joda-time
2.6
xml-apis
xml-apis
1.3.04
xml-apis
xml-apis-ext
1.3.04
org.apache.xmlgraphics
xmlgraphics-commons
1.2
commons-collections
commons-collections
3.2.1
org.aspectj
aspectjweaver
1.8.10
org.apache.poi
poi
3.15
org.apache.activemq
activemq-core
5.7.0
org.springframework
spring-jms
${spring.version}
org.apache.activemq
activemq-all
5.7.0
org.apache.xbean
xbean-spring
3.16
org.springframework
spring-websocket
${spring.version}
org.springframework
spring-messaging
${spring.version}
com.google.code.gson
gson
2.8.0
com.itextpdf
itextpdf
5.5.10
com.itextpdf
itext-asian
5.2.0
org.bouncycastle
bcprov-jdk15on
1.54
org.apache.james
james-server-data-api
3.0.0
activiti_modeler
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.2
true
true
src/main/java
**/*.xml
src/main/resources
**/*
4.新建ModelController.java
package com.zjgt.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@Controller
@RequestMapping("model")
public class ModelController {
@Resource
private RepositoryService repositoryService;
@RequestMapping("create")
public void create(HttpServletRequest request, HttpServletResponse response) {
try {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "abcabc");
editorNode.put("resourceId", "abcabca");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.set("stencilset", stencilSetNode);
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put("name", "LLLLLLL");
modelObjectNode.put("revision", 1);
modelObjectNode.put("description", "没有描述");
Model modelData = repositoryService.newModel();
modelData.setCategory(null);
modelData.setDeploymentId(null);
modelData.setKey(null);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName("流程名称");
modelData.setTenantId("");
modelData.setVersion(1);
//保存模型
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=" + modelData.getId());
} catch (Exception e) {
System.out.println("创建模型失败:");
}
}
}
5.jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/activiti_explorer?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456
6.log4j.properties
log4j.rootLogger=debug,console, log, error
###Console ###
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.Target = System.out
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d %p[%C:%L]- %m%n
### log ###
log4j.appender.log = org.apache.log4j.DailyRollingFileAppender
log4j.appender.log.File = ${webApp.root}/WEB-INF/logs/debug.log
log4j.appender.log.Append = true
log4j.appender.log.Threshold = DEBUG
log4j.appender.log.DatePattern='.'yyyy-MM-dd
log4j.appender.log.layout = org.apache.log4j.PatternLayout
log4j.appender.log.layout.ConversionPattern = %d %p[%c:%L] - %m%n
### Error ###
log4j.appender.error = org.apache.log4j.DailyRollingFileAppender
log4j.appender.error.File = ${webApp.root}/WEB-INF/logs/error.log
log4j.appender.error.Append = true
log4j.appender.error.Threshold = ERROR
log4j.appender.error.DatePattern='.'yyyy-MM-dd
log4j.appender.error.layout = org.apache.log4j.PatternLayout
log4j.appender.error.layout.ConversionPattern =%d %p[%c:%L] - %m%n
###sql
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
Archetype Created Web Application
contextConfigLocation
classpath:spring-mvc.xml,
classpath:spring-mybatis.xml,
classpath:spring-activiti.xml
org.springframework.web.util.IntrospectorCleanupListener
org.springframework.web.context.ContextLoaderListener
org.springframework.web.util.Log4jConfigListener
log4jConfigLocation
classpath:log4j.properties
log4jRefreshInterval
60000
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
true
encoding
UTF-8
forceEncoding
true
encodingFilter
/*
SpringMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
SpringMVC
/
30
index.jsp
index.html
login.jsp
12.部署tomcat后访问 http://localhost:8080/activti_modeler/model/create
12源码下载:http://download.csdn.net/download/duguxingfeng/10150268
13.资源文件下载:http://download.csdn.net/download/duguxingfeng/10150366