最近集成activi 6集成到spring boot中,遇到一些问题,记录一二.
- activiti中的mybaitis版本冲突
集成activit6需引入如下配置
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
</dependency>
但项目启动报如下错误
Caused by: java.lang.NoSuchFieldError: INSTANCE
at com.baomidou.mybatisplus.MybatisMapperAnnotationBuilder.parseStatement(MybatisMapperAnnotationBuilder.java:332) ~[mybatis-plus-core-2.3.jar:?]
at com.baomidou.mybatisplus.MybatisMapperAnnotationBuilder.parse(MybatisMapperAnnotationBuilder.java:153) ~[mybatis-plus-core-2.3.jar:?]
at com.baomidou.mybatisplus.MybatisMapperRegistry.addMapper(MybatisMapperRegistry.java:86) ~[mybatis-plus-core-2.3.jar:?]
at com.baomidou.mybatisplus.MybatisConfiguration.addMapper(MybatisConfiguration.java:101) ~[mybatis-plus-core-2.3.jar:?]
at org.apache.ibatis.builder.xml.XMLMapperBuilder.bindMapperForNamespace(XMLMapperBuilder.java:408) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:94) ~[mybatis-3.4.2.jar:3.4.2]
at com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:583) ~[mybatis-plus-core-2.3.jar:?]
经查,是因为我用mybatis plus,要求用mybatis3.4.6,而activiti用的是mybatis3.4.2,两边有冲突,直接排除activitiv那个即好
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
- activiti中的SecurityAutoConfiguration冲突
启动项目中,报如下错
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) ~[?:1.8.0_181]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) ~[?:1.8.0_181]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) ~[?:1.8.0_181]
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) ~[?:1.8.0_181]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[?:1.8.0_181]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[?:1.8.0_181]
at java.lang.Class.createAnnotationData(Class.java:3521) ~[?:1.8.0_181]
at java.lang.Class.annotationData(Class.java:3510) ~[?:1.8.0_181]
at java.lang.Class.createAnnotationData(Class.java:3526) ~[?:1.8.0_181]
at java.lang.Class.annotationData(Class.java:3510) ~[?:1.8.0_181]
at java.lang.Class.getAnnotation(Class.java:3415) ~[?:1.8.0_181]
at java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258) ~[?:1.8.0_181]
at java.lang.Class.isAnnotationPresent(Class.java:3425) ~[?:1.8.0_181]
at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:573) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:177) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:217) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:188) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:136) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
经查,是类SecurityAutoConfiguration有冲突,在启动时排除该类即可
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class StarmarkApplication {
public static void main(String[] args) {
SpringApplication.run(StarmarkApplication.class, args);
}
}
- activiti中自动搜索流程文件的check-process-definitions问题
项目启动时报如下错误
Caused by: java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:195) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:495) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:296) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1309) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.GenericApplicationContext.getResources(GenericApplicationContext.java:233) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
意思是说,在目录processes/寻找流程文件,这个只要配置一下check-process-definitions即好
activiti:
database-schema-update: true
check-process-definitions: false
至此,activiti6集成的问题记录完毕!