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>
来源:CSDN
作者:Jimmy胡
链接:https://blog.csdn.net/weixin_44732049/article/details/103934623