JavaSpringBootGradle插件2。x如何使用自定义启动器布局工厂
在我的项目中,我使用activeMQ artemis和Spring Boot。应用程序应作为Apache Commons守护程序服务执行。我想在这个项目中使用我的自定义启动器
该项目具有以下渐变配置:
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引导插件的1.5。x版本,因为其依赖关系管理模块会自动将apache activeMQ降级为1.5.5版。 因为这个项目必须作为ApacheCommons守护程序服务执行,所以我必须使用我的定制Spring引导启动器,这使得有一个静态启动器和类加载器成为可能。这两个帮助我停止已经运行的服务
我尝试了以下设置,用以下设置将我的自定义启动器添加到生成的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。或者我必须在这里使用任何变通方法吗
# 1 楼答案
我建议研究一下如何为Artemis^{} 使用Spring Boot starter。它应该在没有任何摩擦的情况下启动嵌入式服务器