简体   繁体   English

编译失败,运行时 scope in Build.gradle?

[英]Compile failed with runtime scope in Build.gradle?

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:我有一个 java web 项目,它基于 gradle 作为构建工具,我有一些 jars 依赖项,我在运行时需要它们,当我在 build.grale 中将它们声明为runtime在 eclipse 代码中没有错误,所有代码看起来都不错没有错误,但是当我在项目中运行gradlew clean build时,我有这个:

Task:compileJava FAILED任务:编译 Java 失败

FAILURE: Build failed with an exception.失败:构建失败,出现异常。

  • What went wrong: Execution failed for task ':compileJava'.出了什么问题:任务“:compileJava”的执行失败。

Compilation failed;编译失败; see the compiler error output for details.有关详细信息,请参阅编译器错误 output。

ALSO when I change the scope to compileOnly the compilation is working fine, but I need it runtime scope!另外,当我将 scope 更改为compileOnly时,编译工作正常,但我需要它的runtime范围!

Is there a solution on how to make the scope runtime and the project compile fine?是否有关于如何使 scope runtime和项目编译正常的解决方案?

Thanks谢谢

You should use implementation in order to make the dependency available both at compile time and at run time.您应该使用implementation以使依赖项在编译时和运行时都可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM