最近在照着某课视频,在魔改activiti6.0 ,整合springboot,真是的欲生欲死,几近进行不下去了!昨天就遇到了一个问题,Unable to start embedded Tomcat,我照着视频上操作,视频过去了,我却出现了这个问题!本来不打算写下这个问题的,今天上班路上,还是觉得有必要写下来,昨天百度了好久,也没有找到具体解决办法。
先简单说下什么原因,因为activiti6.0里面采用了Security框架,所以在整合的时候,需要先排除这些不需要的类。如果你也是看的某课的视频,那你到这里,可以继续按视频往下看,照着操作就行了,到了视频中后面再打开启动类的时候,照着加上需要排除的类即可。
我这边先凭着记忆写下,需要改动的地方,等后面魔改好了,上传一会改好的源码。
目录结构
1.在启动类中加上需要排除的类
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
@SpringBootApplication(exclude = {
SecurityAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
org.activiti.spring.boot.SecurityAutoConfiguration.class
})
2.有个需求说key值为空了,就是因为这个activiti-app.properties中security.rememberme.key=testkey和springboot中冲突了,需要修改,将activiti-app.properties中修为为appconf.security.rememberme.key=testkey,项目中大概有三到四处用到了这个security.rememberme.key,建议使用全局替换,需要全部修改。
appconf.security.rememberme.key=testkey
3.还有地方会说找不到processes文件夹,当你建好文件夹,如果没有文件的话,他还是会报找不到的异常,因为空文件夹,会被默认忽略。照着上面目录结构图操作下就解决了。
4.application.yml文件
#禁用liquibase(用于数据库重构和迁移的开源工具)
liquibase:
enabled: false
#模板路径
spring:
freemarker:
check-template-location: false
activiti:
check-process-definitions: false
#端口
server:
port: 9999
context-path: "/activiti-app"
5.logback.xml文件,可能存在些问题,请有能力的大佬帮助改正下,感谢回复
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="30 seconds">
<property name="log.dir" value="target/logs"/>
<property name="encoding" value="UTF-8"/>
<property name="plain" value="%msg%n"/>
<property name="std" value="%d{HH:mm:ss.SSS}[%thread][%-5level]%msg %X{user} %logger{10}.%M:%L%n"/>
<property name="mdc" value="%d{HH:mm:ss.SSS}[%thread][%-5level]%msg ProcessDefinitionId=%X{mdcProcessDefinitionID}
executionId=%X{mdcExecutionId} mdcProcessInstanceID=%X{mdcProcessInstanceID} mdcBusinessKey=%X{mdcBusinessKey}.%M:%L%n"/>
<property name="normal" value="%d{yyyy-MM-dd:HH:mm:ss.SSS}[%thread][%-5level] %logger{10}.%M:%L %msg%n"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${mdc}</pattern>
<charset>${encoding}</charset>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/activiti6.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>
<logger name="root">
<level>ERROR</level>
</logger>
<logger name="com.bulin.activiti6">
<level>DEBUG</level>
</logger>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<!--<appender-ref ref="FILE" />-->
</root>
</configuration>
6.后面还会加两个依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
这里我也放出这个pom文件,所有的依赖,用来给各位参考
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.activiti</groupId>
<artifactId>activiti-ui-root</artifactId>
<version>6.0.0-boot2</version>
</parent>
<artifactId>activiti-app</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-app-conf</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.2.6.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<!-- BUILD -->
<build>
<finalName>activiti-app</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.2.6.RELEASE</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/activiti-app</path>
<port>9999</port>
<protocol>org.apache.coyote.http11.Http11NioProtocol</protocol>
<systemProperties>
<com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven
build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.zeroturnaround
</groupId>
<artifactId>
jrebel-maven-plugin
</artifactId>
<versionRange>
[1.1.1,)
</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
7.还会排除conf包中的两个类,直接全选注释就可以了
conf修改了,别忘了安装下
到这里记忆里面的都写了,至于还有那些没写到,就记不起了,实现了会上传一份源码,魔改好了,大家直接用就可以了,activiti6.0实在是繁琐。至于那些类为什么会被排除,其实百度都有很多老程分析过了,感兴趣可以自己百度下。
此致
敬礼