美文网首页
spring boot工程使用gradle打包

spring boot工程使用gradle打包

作者: sweetMemories | 来源:发表于2017-07-22 15:38 被阅读0次
    • 配置文件范例
    • 注意: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

    相关文章

      网友评论

          本文标题:spring boot工程使用gradle打包

          本文链接:https://www.haomeiwen.com/subject/qasukxtx.html