我最近为 Spring Boot 项目将 Gradle 从 4.x 升级到 6.6。我以为我终于把它全部启动并运行了,但后来意识到我们的一个应用程序可能启动两个不同配置的类型任务BootRun(例如 A 和 B),却无法启动第二个 B 实例。
这是我尝试运行第二个实例时出现的错误:
Build file 'C:\Users\...\build.gradle' line: 17
Execution failed for task ':apps:myapp:bootRunB'.
> The value for task ':apps:myapp:bootRunB' property 'mainClass' is final and cannot be changed any further.
Run Code Online (Sandbox Code Playgroud)
build.gradle这是我的文件中配置任务的部分:
task bootRunB(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
group = 'Application'
doFirst() {
main = bootJar.mainClassName
classpath = bootRun.classpath
systemProperty '...'
}
}
Run Code Online (Sandbox Code Playgroud)
任何建议,将不胜感激。