在我的项目中,我使用的是 activeMQ artemis 和 Spring Boot。该应用程序应作为 Apache Commons Daemon 服务执行。我想在这个项目中使用我的自定义启动器。
该项目具有以下 Gradle 配置:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M7")
}
}
plugins {
id "org.sonarqube" version "2.6.1"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
ext {
commonsDaemonVersion = '1.1.0'
artemis = '2.4.0'
}
dependencies {
compile("org.apache.activemq:artemis-server:${artemis}")
compile("org.apache.activemq:artemis-core-client:${artemis}")
compile("commons-daemon:commons-daemon:${commonsDaemonVersion}")
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
因为我用的是activeMQ artemis,所以不能使用Spring Boot Plugin的1.5.x版本,因为它的依赖管理模块会自动将apache activeMQ降级到1.5.5版本。因为这个项目必须作为 Apache Commons Daemon Service 执行,所以我必须使用我的自定义 Spring Boot 启动器,这使得拥有静态启动器和类加载器成为可能。这两个帮助我停止已经运行的服务。
我尝试了以下设置,以使用以下设置将我的自定义启动器添加到生成的 jar 文件中。但是,这不是正确的方法,因为我必须手动将启动器的类名添加到清单文件中。
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M7")
}
}
plugins {
id "org.sonarqube" version "2.6.1"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
ext {
commonsDaemonVersion = '1.1.0'
artemis = '2.4.0'
}
configurations {
launcher
}
dependencies {
compile("org.apache.activemq:artemis-server:${artemis}")
compile("org.apache.activemq:artemis-core-client:${artemis}")
compile("commons-daemon:commons-daemon:${commonsDaemonVersion}")
launcher("com.mycompany.springboot.launcher:my-custom-launcher:0.1.0-RELEASE")
}
bootJar {
from project.configurations.launcher.each {
from(zipTree(it))
}
manifest {
attributes 'Main-Class': 'com.mycompany.springboot.launcher.CustomLauncher'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
在 1.5.x 版本中,我可以使用以下选项来添加我的启动器配置:
springBoot {
layoutFactory = new com.mycompany.springboot.launcher.CustomLauncherFactory()
}
是否有任何设置,我可以使用它来添加带有 Spring Boot Gradle 插件 2.x 的自定义启动器,还是我必须在这里使用任何解决方法?