【发布时间】:2021-09-29 08:12:06
【问题描述】:
在尝试运行我的应用程序时,我收到两个错误,第一个错误
1.
Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.0-rc-1-bin.zip'.
Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jdk-17
第二个是告诉我在我的应用程序中找不到我的“主要”方法。我的源代码都很好,因为我的朋友能够在他的机器上运行完全相同的源代码。
但是,我注意到当他运行应用程序时,会自动创建一个 .gradle 文件夹,但对我来说没有创建这样的文件夹
我的朋友文件结构
我的文件结构
我在下面附上了我的文件结构和他的文件结构,以及我的 build.gradle 文件。
我注意到我的项目不存在 .gradle 文件,但他的项目存在(这是相同的未修改源代码)
这是我的 build.gradle 文件
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.sparkjava:spark-core:2.9.3'
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.+'
implementation 'org.junit.jupiter:junit-jupiter:5.8.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter:5.8.0'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
version = '1.2.1'
apply plugin: 'application'
apply plugin: 'eclipse'
sourceSets {
main {
java {
srcDir 'src/main'
}
}
test {
java {
srcDir 'src/test'
}
}
}
mainClassName = 'uni.App'
test {
useJUnitPlatform()
}
【问题讨论】:
-
您的系统上是否存在
C:\Program Files\Java\jdk-17目录?如果存在,它包含什么 -
简单的Java安装。
标签: java gradle visual-studio-code build