向我的项目添加依赖项时,我不确定应该给它们什么前缀,例如 "classpath"
或 "compile".
例如,我下面的依赖项应该是编译时还是类路径?
另外,这应该在我的 应用程序 build.gradle 中还是在 模块 特定的 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'
}
原文由 java123999 发布,翻译遵循 CC BY-SA 4.0 许可协议
我猜你在
dependencies {}
块中引用了compile
和classpath
。如果是这样,那么这些就是依赖 Configurations 。compile
配置由 Java 插件创建。classpath
配置在buildScript {}
块中很常见,其中需要声明 build.gradle 本身的 依赖项(可能是插件)。