英文:
Compile failed with runtime scope in Build.gradle?
问题
我有一个基于Gradle构建工具的Java Web项目,
我有一些在运行时需要的jar依赖项,
当我在build.gradle
中将它们声明为runtime
时,
在Eclipse代码中没有错误,所有代码看起来都很好,没有错误,
但是当我在项目中运行gradlew clean build
时,我得到了这个错误:
> 任务:compileJava 失败
>
> 失败:构建过程因异常而失败。
>
> * 失败原因:执行任务':compileJava'失败。
> > 编译失败;有关详细信息,请参阅编译器错误输出。
另外,当我将范围更改为compileOnly
时,编译工作正常,但我需要它是runtime
范围!
有没有办法让范围保持为runtime
并且项目能够成功编译?
谢谢
英文:
I have a java web project which is based on gradle as build tool,
I have some jars dependencies which I need them at runtime and when I declare them as runtime
in the build.grale In eclipse code there are no errors and all code looks nice without errors but when I run gradlew clean build
in the project I have this:
> Task :compileJava FAILED
>
> FAILURE: Build failed with an exception.
>
> * What went wrong: Execution failed for task ':compileJava'.
> > Compilation failed; see the compiler error output for details.
ALSO when I change the scope to compileOnly
the compilation is working fine, but I need it runtime
scope!
Is there a solution on how to make the scope runtime
and the project compile fine ?
Thanks
答案1
得分: 1
你应该使用 implementation
,以便在编译时和运行时都使依赖可用。
英文:
You should use implementation
in order to make the dependency available both at compile time and at run time.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论