Activity5入门案例

导入依赖

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring-boot-starter-basic</artifactId>
    <version>5.21.0</version>
</dependency>
<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- 数据库连接池 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.1.1</version>
</dependency>

添加配置

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://127.0.0.1:3306/crowdfunding
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
mybatis:
  mapperLocations: classpath*:mybatis/mapper-*.xml
  typeAliasesPackage: cn.ishangit.**.bean

编写测试程序

package cn.ishangit.helloactivity5;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RepositoryService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class HelloActivity5ApplicationTests {

    @Autowired
    private ProcessEngine processEngine ;

    @Autowired
    private RepositoryService repositoryService ;



    @Test
    public void contextLoads() {
        System.out.println( processEngine );
        System.out.println(repositoryService);
    }

}

遇到的错误1:

java.lang.NoClassDefFoundError: org/apache/ibatis/annotations/Mapper

原因:因为我们的流程框架引用的是mybatis版本与springboot-starter引用的版本不一致

解决:把activity的依赖放到springboot-starter的后面

遇到的错误2:

FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist

解决:在resources目录下创建processes文件夹

遇到的错误3:

Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxyatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708)

原因:springboot1springboot2部分自动配置类的包不同

解决:修改springboot版本为1.x的版本

结果

最后运行成功可以看到activity5框架帮我们生成了自带的25张表。

image92826f01281d26c2.png

转载于:https://www.cnblogs.com/chen88/p/11538427.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值