1. 程式人生 > >IDEA Gradle 打包 Spring Boot 1.5x 可執行的jar檔案流程

IDEA Gradle 打包 Spring Boot 1.5x 可執行的jar檔案流程

build.gradle檔案:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

jar {
baseName = 'gs-rest-service'
version = '0.1.0' } repositories { mavenCentral() } sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.security.oauth:spring-security-oauth2"
) compile("org.springframework.boot:spring-boot-starter-data-redis") compile("org.springframework.session:spring-session") testCompile('org.springframework.boot:spring-boot-starter-test') compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1") compile 'mysql:mysql-connector-java' compile group: 'org.apache.commons'
, name: 'commons-lang3', version: '3.7' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.46' }

打包流程圖:

陳科肇

開啟Gradle視窗->找到樹節點[你的專案名稱]/Tasks/build/bootRepackage->雙擊一下,就開始編譯打包jar檔案了,最終會在你專案目錄下的build裡找到jar檔案。

使用:

雙擊jar檔案,或者java -jar **.jar