在向项目添加依赖项时,我无法确定应该给它们的前缀,例如"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'
}
Run Code Online (Sandbox Code Playgroud) 我已经对“类路径上已有的插件的插件请求不得包含版本站点:stackoverflow.com”进行了网络搜索,但没有发现任何特别的东西。搜索“已在类路径上的插件的插件请求不得包含版本”(不带 SO)找到:https : //discuss.gradle.org/t/error-plugin-already-on-the-classpath-must -not-include-a-version/31814我读过的答案,例如:
我在 Grade 插件文档中没有找到对这个用例的任何参考。
错误
构建文件 '/Users/username/github/OpCon/app/build.gradle' 行:4 解析插件时出错 [id:'com.android.application',版本:'3.4.1']
已在类路径上的插件的插件请求不得包含版本
出现在IntelliJ IDEA,build.gradle(OpCon)中:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
} …Run Code Online (Sandbox Code Playgroud)