spring boot工程使用gradle打包
2017-07-22 本文已影响0人
sweetMemories
- 配置文件范例
- 注意:1.注意去除'war'插件;2.Main-Class参数的值须为启动application的class
buildscript {
ext {
springBootVersion = '1.5.4.RELEASE'
}
repositories {
mavenLocal()
maven { url = "http://maven.aliyun.com/nexus/content/groups/public" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
//apply plugin: 'war'
apply plugin: 'org.springframework.boot'
version = '1.0.0'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url = "http://maven.aliyun.com/nexus/content/groups/public" }
mavenCentral()
}
dependencies {
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.0')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('com.github.pagehelper:pagehelper-spring-boot-starter:1.1.1')
compile('com.alibaba:druid:1.0.31')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
jar {
manifest {
attributes 'Main-Class': 'net.mrpotato.CouponApplication'
}
}
- gradle命令,到build.gradle所在目录下运行如下命令即可
gradle bootRepackage
- 运行jar包命令,到xxx.jar所在目录下运行如下命令即可
java -jar xxx.jar