spring boot工程使用gradle打包

  • 配置文件范例
  • 注意: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 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,948评论 6 342
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,914评论 18 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,242评论 25 708
  • 转载注明出处:http://www.jianshu.com/p/5255b100930e 0. 前言 完全由个人翻...
    王三的猫阿德阅读 2,561评论 0 4
  • 好久没来你的世界 步履维艰揣着胆怯 时隔数月的愚人节 手足无措似来赴劫 我还惦记上次送别 缝进平安福的那些 两个名...
    夏小溪_阅读 216评论 0 3