gpt4 book ai didi

jetty - 启动 JettyRun 时排除 Gradle 类路径运行时

转载 作者:行者123 更新时间:2023-12-04 12:49:14 25 4
gpt4 key购买 nike

我有您基本运行的磨房 Gradle Web 应用程序项目,它工作正常,但我注意到 Gradle 的运行时类路径包含在 jetty 之一中,它有可能与 Web 应用程序发生冲突。

请注意,下面的 gradle 使用的是稍旧版本的 logback,并且 SL4J 警告它在类路径中发现了多个绑定(bind)。

:jettyRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/dev/java/tools/gradle-1.0-milestone-5/lib/logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/kirk.rasmussen/.gradle/caches/artifacts-3/ch.qos.logback/logback-classic/fd9fe39e28f1bd54eee47f04ca040f2b/jars/logback-classic-0.9.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

有没有办法在运行 jettyRun 任务时排除 gradle 运行时类路径?我正在使用最新的 1.0 里程碑 5 版本的 Gradle。

我正在 Ant 的 javac 任务中寻找类似于“includeAntRuntime”的内容。

http://ant.apache.org/manual/Tasks/javac.html

includeAntRuntime 是否在类路径中包含 Ant 运行时库;默认为 yes,除非设置了 build.sysclasspath。通常最好将此设置为 false,这样脚本的行为对其运行的环境不敏感。

剥离 build.gradle:
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'jetty'

jettyRun {
contextPath = ''
}

最佳答案

manual for jettyRun 中所述任务,它有一个 classpath默认设置为 project.sourceSets.main.runtimeClasspath 的属性.您可以将此属性设置为您选择的类路径:

configurations{
myJettyRuntime
}

dependencies{
myJettyRuntime "group:name:version"
...
}

jettyRun{
classpath = configurations.myJettyRuntime
}

或者,您可以使用 -= 在该类路径中添加或减去不需要或冲突的依赖项。和 +=运营商分别。
jettyRun{
classpath -= configurations.myExcludedConf
}

关于jetty - 启动 JettyRun 时排除 Gradle 类路径运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7982507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com