gradle maven 打包

回眸只為那壹抹淺笑 提交于 2020-01-11 15:37:12

gradle 打war

bootJar


package com.jekjk.replenishment;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class MyServletInitializer  extends SpringBootServletInitializer {
    //打包程序使用
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ShopReplenishmentApplication.class);//这里的这个类就是启动spring boot的那个运行类
    }
}





plugins {
    id 'java'
    id 'java-library'
    id 'war'
    id 'org.springframework.boot' version '2.2.2.RELEASE'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.t'
version = '0.0.1-SNAPSHOT'

ext {
    springBootVersion = '2.2.2.RELEASE'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

apply plugin: 'war'

war {

    from('src/main/java') {
        include 'mapper/*.xml'
    }

}

processResources {

    from('src/main/java') {
        include '**/*'
        exclude "**/*.java"
    }
}

sourceSets {
    main {
        resources {
            srcDir "src/main/java"
        }
    }

}

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            def url = repo.url.toString()
            if ((repo instanceof MavenArtifactRepository) && (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com'))) {
                project.logger.lifecycle 'Repository ${repo.url} replaced by $REPOSITORY_URL .'
                remove repo
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}
dependencies {
    compile group: 'org.apache.rocketmq', name: 'rocketmq-client', version: '4.2.0'

    runtime(group: 'mysql', name: 'mysql-connector-java', version: '8.0.18') {
        exclude(module: 'protobuf-java')
    }
    testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.2.2.RELEASE') {
        exclude(module: 'junit-vintage-engine')
    }
}



gradle 转 maven 打包



  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!