Activiti学习之springboot与activiti整合
声明:本⽂是springboot2.0的多项⽬构建,springboot2.0和spingboot1.5的配置是有出⼊的,构建项⽬之前请规范您的springboot版本,选择2.0以上。
⼀、在IDEA中使⽤⼯具创建SpringBoot + Gradle的⽗⼯程
new -> project ->gradle
⼆、在⽗⼯程下新建叁个模块 dao service web
右键单击⽗⼯程 new -> module -> Spring Initializr -> type选项选中Gradle Project(其他视情况填写)
创建module的最后⼀步要注意,⼦模块最好在⽗⼯程的⽬录下,避免不必要的⿇烦
创建每个模块的时候有⼀个让你选择加载jar包的过程你可以选也可以不选我建议什么都不⽤项⽬创建完毕根据项⽬需求⼿动在adle⽬录下加⼊你需要的jar包
三、以此类推创建service模块和web模块作为项⽬的⼦模块
四、重要的事情说三遍(很重要)
修改⽗项⽬也就是sys(第⼀个创建的gradle项⽬)下的adle⽂件,加⼊
include 'dao','service',"web"
此代码表⽰ dao ,service ,web 这三个项⽬是他的⼦项⽬如果不加⼊后⾯在⽗项⽬中定义的所有规范将毫⽆意义
五、⽗项⽬下adle代码
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
group = 'com.huyuqiang'
version = '0.0.1-SNAPSHOT'
//jvm(java虚拟机版本号)第⼀个是你项⽬使⽤的jdk版本第⼆个是你项⽬运⾏的jdk版本
sourceCompatibility = 1.8
targetCompatibility = 1.8
springboot中文}
subprojects {
ext {
//版本号定义
springBootVersion = '2.0.3.RELEASE'
}
// java编译的时候缺省状态下会因为中⽂字符⽽失败
[compileJava, compileTestJava, javadoc].ding = 'UTF-8'
repositories {
mavenLocal()
maven { url "" }
maven { url "" }
mavenCentral()
jcenter()
}
configurations {
all*.exclude module: 'commons-logging'
}
}
/
/定义⼦项⽬dao的配置
project(':dao') {
dependencies {
compile(
//redis缓存框架随便加的⾃⼰项⽬中需要什么加什么
'org.springframework.boot:spring-boot-starter-data-redis'
//'org.springframework.boot:spring-boot-starter-jdbc',
//'batis.spring.boot:mybatis-spring-boot-starter:1.3.2'
)
testCompile(
'org.springframework.boot:spring-boot-starter-test',
"junit:junit:4.12"
)
}
}
//定义⼦项⽬service的配置
project(':service') {
dependencies {
//service依赖于dao
compile project(":dao")
compile(
'org.springframework.boot:spring-boot-starter-web',
)
testCompile(
'org.springframework.boot:spring-boot-starter-test',
"junit:junit:4.12"
)
}
}
project(':web') {
apply plugin: "war"
dependencies {
//web依赖于service
compile project(":service")
compile(
'org.springframework.boot:spring-boot-starter-web'
)
testCompile(
'org.springframework.boot:spring-boot-starter-test',
"junit:junit:4.12"
)
// providedCompile(
// "javax.servlet:javax.servlet-api:3.1.0",
// "javax.servlet.jsp:jsp-api:2.2.1-b03",
// "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1"
/
/ )
}
processResources{
/从'$projectDir/src/main/java'⽬录下复制⽂件到'WEB-INF/classes'⽬录下覆盖原有同名⽂件/ from("$projectDir/src/main/java")
}
</span><span >/*</span><span >⾃定义任务⽤于将当前⼦项⽬的java类打成jar包,此jar包不包含resources下的⽂件</span><span >*/</span><span > def jarArchiveName</span>="${project.name}-${version}.jar"<span >
task jarWithoutResources(type: Jar) {
from sourceSets.main.output.classesDir
archiveName jarArchiveName
}
</span><span >/*</span><span >重写war任务:</span><span >*/</span><span >
war {
dependsOn jarWithoutResources
</span><span >/*</span><span > classpath排除sourceSets.main.output.classesDir⽬录,加⼊jarWithoutResources打出来的jar包 </span><span >*/</span><span $buildDir/$libsDirName/$jarArchiveName"<span >))
}
</span><span >/*</span><span >打印编译运⾏类路径</span><span >*/</span><span >
task jarPath </span><<<span > {
println configurationspile.asPath
}
}
/从⼦项⽬拷贝War任务⽣成的压缩包到根项⽬的build/explodedDist⽬录/
task explodedDist(type: Copy) {
into "$buildDir/explodedDist"
subprojects {
from tasks.withType(War)
}
}
六、⼦项⽬dao中adle代码
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.huyuqiang'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url "" }
maven { url "" }
mavenCentral()
jcenter()
}
dependencies {
testCompile('org.springframework.boot:spring-boot-starter-test')
}
七、⼦项⽬service中adle代码
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.huyuqiang'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url "" }
maven { url "" }
mavenCentral()
jcenter()
}
dependencies {
testCompile('org.springframework.boot:spring-boot-starter-test')
}
⼋、⼦项⽬web中adle代码
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.huyuqiang'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url "" }
maven { url "" }
mavenCentral()
jcenter()
}
configurations {
providedRuntime
}
dependencies {
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
}
九、在web⼦模块下创建controller⽂件夹,⽂件夹下创建⼀个controller类,请看清楚我截图的包结构,如果包结构不对,启动项⽬的时候访问⽹页会报错(Whiteable Error Page) ),这是springboot有默认的包结构,如果你的包结构不对spring启动的时候是不到
你的controller类的
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论