Gradle: What is the difference between classpath and compile dependencies?(Gradle:类路径和编译依赖有什么区别?)
问题描述
向我的项目添加依赖项时,我永远不确定应该给它们什么前缀,例如"classpath"
或 "compile".
When adding dependencies to my project I am never sure what prefix I should give them, e.g. "classpath"
or "compile".
例如,我下面的依赖项应该是编译时间还是类路径?
For example, should my dependencies below be compile time or classpath?
另外,这应该在我的 applications build.gradle 中还是在 module 特定的 build.gradle 中?
Also, should this be in my applications build.gradle or in the module specific build.gradle?
当前 build.gradle(在应用程序级别):
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'org.hibernate:hibernate-core:5.0.5.Final'
compile 'mysql:mysql-connector-java:5.1.38'
}
推荐答案
我猜你在 中引用了
块.如果是这样,那些是依赖配置.compile
和 classpath
依赖项 {}
I'm going to guess that you're referencing compile
and classpath
within the dependencies {}
block. If that is so, those are dependency Configurations.
配置只是一组命名的依赖项.
A configuration is simply a named set of dependencies.
compile
配置由 Java 插件创建.classpath
配置常见于 buildSrc {}
块中,其中需要为 build.gradle 本身声明依赖项(对于插件,也许).
The compile
configuration is created by the Java plugin. The classpath
configuration is commonly seen in the buildSrc {}
block where one needs to declare dependencies for the build.gradle, itself (for plugins, perhaps).
这篇关于Gradle:类路径和编译依赖有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Gradle:类路径和编译依赖有什么区别?


基础教程推荐
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01