• actitivi 6.0.X工作流引擎集成app-editor详细操作


    1、修改activiti-ui包下不必要的代码;详细参见教程。后面附上

     

    2、新建启动类。

    package com.cy.ops.workflow;
    
    import org.activiti.app.conf.ApplicationConfiguration;
    import org.activiti.app.servlet.ApiDispatcherServletConfiguration;
    import org.activiti.app.servlet.AppDispatcherServletConfiguration;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
    import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.context.embedded.ServletRegistrationBean;
    import org.springframework.boot.context.web.SpringBootServletInitializer;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Import;
    import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
    import org.springframework.web.servlet.DispatcherServlet;
    
    /**
     * @Description: 启动类
     * @Author: zhaoyingchao
     * @CreateDate: 2018/11/25 19:11:54
     * @Version: 6.0.0-CY
     */
    @SpringBootApplication(exclude = {
        SecurityAutoConfiguration.class,
        org.activiti.spring.boot.SecurityAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,
        SecurityAutoConfiguration.class
    })
    @Import({ApplicationConfiguration.class})
    public class WorkflowApplication extends SpringBootServletInitializer {
    
        public static void main(String[] args) {
            SpringApplication.run(WorkflowApplication.class, args);
        }
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
            return builder.sources(WorkflowApplication.class);
        }
    
        @Bean
        public ServletRegistrationBean apiDispatcher() {
            DispatcherServlet api = new DispatcherServlet();
            api.setContextClass(AnnotationConfigWebApplicationContext.class);
            api.setContextConfigLocation(ApiDispatcherServletConfiguration.class.getName());
            ServletRegistrationBean registrationBean = new ServletRegistrationBean();
            registrationBean.setServlet(api);
            registrationBean.addUrlMappings("/api/*");
            registrationBean.setLoadOnStartup(1);
            registrationBean.setAsyncSupported(true);
            registrationBean.setName("api");
            return registrationBean;
        }
    
    // app登录、访问需要
        @Bean
        public ServletRegistrationBean appDispatcher() {
            DispatcherServlet app = new DispatcherServlet();
            app.setContextClass(AnnotationConfigWebApplicationContext.class);
            app.setContextConfigLocation(AppDispatcherServletConfiguration.class.getName());
            ServletRegistrationBean registrationBean = new ServletRegistrationBean();
            registrationBean.setServlet(app);
            registrationBean.addUrlMappings("/app/*");
            registrationBean.setLoadOnStartup(1);
            registrationBean.setAsyncSupported(true);
            registrationBean.setName("app");
            return registrationBean;
        }
    }
    

     3、增加依赖pom

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.cy.ops</groupId>
        <artifactId>workflow_test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>workflow_test</name>
        <description>Spring Boot Workflow</description>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.2.6.RELEASE</version>
            <relativePath/>
        </parent>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <spring.version>4.1.6.RELEASE</spring.version>
            <spring.security.version>4.0.1.RELEASE</spring.security.version>
            <hibernate.version>4.2.16.Final</hibernate.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-hateoas</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>5.0.2.Final</version>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <scope>runtime</scope>
            </dependency>
    
            <!-- activiti-ui -->
            <dependency>
                <groupId>org.activiti</groupId>
                <artifactId>activiti-spring-boot-starter-basic</artifactId>
                <version>6.0.0-CY</version>
            </dependency>
    
            <dependency>
                <groupId>org.activiti</groupId>
                <artifactId>activiti-app-conf</artifactId>
                <version>6.0.0-CY</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-crypto</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <configuration>
                        <path>/workflow</path>
                        <port>8080</port>
                        <protocol>org.apache.coyote.http11.Http11NioProtocol</protocol>
                        <systemProperties>
                            <com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
                        </systemProperties>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>

    尤其注意如下依赖冲突,特别费时费力。

     <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <spring.version>4.1.6.RELEASE</spring.version>
            <spring.security.version>4.0.1.RELEASE</spring.security.version>
            <hibernate.version>4.2.16.Final</hibernate.version>
        </properties>

    4、修改web登录地址

    5、tomcat启动需要移除如下配置

    6、汉化

    详细可以从如下地方下载

    https://download.csdn.net/download/zyc88888/10815797

    7、spring boot启动需要打包参见如下配置

    <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/webapp</directory>
                    <!--注意此次必须要放在此目录下才能被访问到 -->
                    <targetPath>META-INF/resources</targetPath>
                    <includes>
                        <include>**/**</include>
                    </includes>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                    <includes>
                        <include>**/*</include>
                    </includes>
                </resource>
                <resource>
                    <directory>src/main/java</directory>
                    <excludes>
                        <exclude>**/*.java</exclude>
                    </excludes>
                </resource>
            </resources>
        </build>
    

    9、增加driud或者其他方式;适配mysql数据库

    spring:
      application:
        name: workflow
      datasource:
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://127.0.0.1:3306/activiti?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=UTC&nullCatalogMeansCurrent=true&&verifyServerCertificate=false&useSSL=false&allowPublicKeyRetrieval=true
        username: root
        password: passwd
      activiti:
        jpa-enabled: true
        async-executor-activate: false
        rest-api-enabled: true
        databaseSchemaUpdate: true
        check-process-definitions: false
        history-level: full
        create:
          admin:
            users: true
      jpa:
        show-sql: true
        hibernate:
          ddl-auto: update
        database: mysql
    #      url: jdbc:mysql://192.168.201.46:3306/927_dev_fd_online?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
    #      username: cy_fdonline
    #      password: AEKsdD3EberOEk
    server:
      port: 9010
    
    logging:
      config: classpath:logback-workflow.xml
    
    eureka:
      client:
        serviceUrl:
          defaultZone: http://192.168.3.194:32100/eureka,http://192.168.3.194:32101/eureka
      instance:
        instance-id: ${spring.cloud.client.ipAddress}:${server.port}
        ip-address: 192.168.3.8
        prefer-ip-address: true
    
    liquibase:
      enabled: false
    
    debug: true

     或者自定义数据源

    package com.cy.workflow.conf;
    
    import javax.sql.DataSource;
    
    import org.activiti.engine.FormService;
    import org.activiti.engine.HistoryService;
    import org.activiti.engine.IdentityService;
    import org.activiti.engine.ManagementService;
    import org.activiti.engine.ProcessEngine;
    import org.activiti.engine.RepositoryService;
    import org.activiti.engine.RuntimeService;
    import org.activiti.engine.TaskService;
    import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
    import org.activiti.spring.ProcessEngineFactoryBean;
    import org.activiti.spring.SpringProcessEngineConfiguration;
    import org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.boot.context.properties.ConfigurationProperties;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.jdbc.datasource.DataSourceTransactionManager;
    import org.springframework.transaction.PlatformTransactionManager;
    /**
     * @author zhao.yingchao on 2018/11/27
     * @since v1.0.0
     */
    @Configuration
    public class WorkFlowEngineConfiguration extends AbstractProcessEngineAutoConfiguration {
    
        private final Logger log = LoggerFactory.getLogger(WorkFlowEngineConfiguration.class);
    
    
        @Bean(name = "transactionManager")
        public PlatformTransactionManager annotationDrivenTransactionManager(DataSource dataSource) {
            DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
            transactionManager.setDataSource(dataSource);
            return transactionManager;
        }
    
        @Bean
        public ProcessEngineFactoryBean processEngineFactoryBean(ProcessEngineConfigurationImpl config) {
            ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
            factoryBean.setProcessEngineConfiguration(config);
            return factoryBean;
        }
    
        @Bean
        public ProcessEngine processEngine(ProcessEngineFactoryBean bean) {
            // Safe to call the getObject() on the @Bean annotated
            // processEngineFactoryBean(), will be
            // the fully initialized object instanced from the factory and will NOT
            // be created more than once
            try {
                ProcessEngine engine = bean.getObject();
                if (log.isDebugEnabled()) {
                    log.debug(String.format("ProcessEngine [%s] Version: [%s]", engine.getName(), ProcessEngine.VERSION));
                }
                return engine;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    
        @Bean
        @ConfigurationProperties(prefix = "activiti")
        public ProcessEngineConfigurationImpl processEngineConfiguration(DataSource dataSource,
                                                                         PlatformTransactionManager transactionManager) {
            SpringProcessEngineConfiguration cfg = new SpringProcessEngineConfiguration();
            cfg.setDataSource(dataSource);
            cfg.setTransactionManager(transactionManager);
            return cfg;
        }
    
        @Bean
        public RuntimeService createRuntimeService(ProcessEngine processEngine) {
            return processEngine.getRuntimeService();
        }
    
        @Bean
        public RepositoryService createRepositoryService(ProcessEngine processEngine) {
            return processEngine.getRepositoryService();
        }
    
        @Bean
        public TaskService createTaskService(ProcessEngine processEngine) {
            return processEngine.getTaskService();
        }
    
        @Bean
        public ManagementService createManagementService(ProcessEngine processEngine) {
            return processEngine.getManagementService();
        }
    
        @Bean
        public IdentityService createIdentityService(ProcessEngine processEngine) {
            return processEngine.getIdentityService();
        }
    
        @Bean
        public HistoryService createHistoryService(ProcessEngine processEngine) {
            return processEngine.getHistoryService();
        }
    
        @Bean
        public FormService createFormService(ProcessEngine processEngine) {
            return processEngine.getFormService();
        }
    
    }
    

    10、登录

    汉化包:https://download.csdn.net/download/zyc88888/10815797 

    正因为当初对未来做了太多的憧憬,所以对现在的自己尤其失望。生命中曾经有过的所有灿烂,终究都需要用寂寞来偿还。
  • 相关阅读:
    Ubuntu开机自动挂载Windows分区
    Ubuntu 修改hosts
    线程安全
    可重入
    java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet问题
    两数相加
    2017-2018 ACM-ICPC, Central Europe Regional Contest (CERC 17)
    Anniversary party
    k倍区间
    算法训练 素因子去重
  • 原文地址:https://www.cnblogs.com/candlia/p/11919995.html
Copyright © 2020-2023  润新知