解决内网开发springboot整合activiti无法引入或者启动报错问题,自己做记录用的

在开发中遇到的问题:在局域网中开发,springboot整合activiti 在pom 文件中引入

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring-boot-starter-basic</artifactId>
    <version>5.22.0</version>

</dependency>

pom文件会报错  ,activiti依赖  jar包找不到(当然在私服上的jar  是通过拷贝进去的,当然是maven 格式的)。

能力有限,反正没解决这个在局域网依赖的问题,所以就用了最传统的方法  在resources 下创建一个lib包 然后将activiti所有的包放进去,然后在使用activiti 中的service 如:TaskService , HistoryService , RuntieService 等,我们通过

@Autowired
private TaskService taskService;

 

这种方式去注入引用,这样会报空指针异常,所以解决办法就是写一个工具类去实例化,如:

package com.cf.hczz.util;

import org.activiti.engine.*;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;

/**
 * activiti使用工具类
 */
public class ActivitiUtil {

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

    private static ActivitiUtil activitiUtil;

    private RepositoryService repositoryService = processEngine.getRepositoryService();

    private TaskService taskService = processEngine.getTaskService();

    private RuntimeService runtimeService = processEngine.getRuntimeService();

    private HistoryService historyService = processEngine.getHistoryService();


    public static ActivitiUtil instance() {
        if (null == activitiUtil) {
            activitiUtil = new ActivitiUtil();
        }
        return activitiUtil;
    }

    public class init {


    }

    public RepositoryService getRepositoryService() {
        return repositoryService;
    }

    public void setRepositoryService(RepositoryService repositoryService) {
        this.repositoryService = repositoryService;
    }

    public TaskService getTaskService() {
        return taskService;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }

    public RuntimeService getRuntimeService() {
        return runtimeService;
    }

    public void setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
    }

    public HistoryService getHistoryService() {
        return historyService;
    }

    public void setHistoryService(HistoryService historyService) {
        this.historyService = historyService;
    }
}

在使用的时候可以如下使用:

ActivitiUtil.instance().getRepositoryService().crateDeployent.name("kkkk")
.addClasspathResource("xxxx")..addClasspathResource("sss").deploy();

这样就解决了空指针的问题。

 

展开阅读全文

没有更多推荐了,返回首页