Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决我的唯一java错误:无效源代码版本:1-_Java_Gradle_Intellij Idea - Fatal编程技术网

如何解决我的唯一java错误:无效源代码版本:1-

如何解决我的唯一java错误:无效源代码版本:1-,java,gradle,intellij-idea,Java,Gradle,Intellij Idea,我知道有很多与此类似的问题,但它们没有涵盖我的情况:“1-”,其中-不是占位符或负数,而是错误日志所述的内容 10:01:41: Executing task 'build'... Starting Gradle Daemon... Gradle Daemon started in 4 s 748 ms > Configure project : Java: 14.0.1 JVM: 14.0.1+7(Oracle Corporation) Arch: amd64 New Dep: ne

我知道有很多与此类似的问题,但它们没有涵盖我的情况:“1-”,其中
-
不是占位符或负数,而是错误日志所述的内容

10:01:41: Executing task 'build'...

Starting Gradle Daemon...
Gradle Daemon started in 4 s 748 ms

> Configure project :
Java: 14.0.1 JVM: 14.0.1+7(Oracle Corporation) Arch: amd64
New Dep: net.minecraftforge:forge:1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> error: invalid source release: 1.-

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 33s
1 actionable task: 1 executed
10:02:18: Task execution finished 'build'.


我尝试了几种解决方案来回答包含确切数字的问题,这些数字描述了什么源代码版本是无效的,但没有一种有效。它昨天工作正常,在我重新启动IntelliJ后停止工作。

结果是,在关闭IntelliJ时,IntelliJ在我的build.gradle中重写了sowmething:

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' + '' // Need this here so eclipse task generates correctly.
应该是吧 但事实是:

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.-' + 
'' // Need this here so eclipse task generates correctly.

说“这不是复制品”并不自动如此。我想说这一部分在某种程度上解释了你的问题:“这个版本中使用了不推荐的Gradle功能,使它与Gradle 5.0不兼容。”我昨天重新启动intellij后它工作正常,现在我明白了,我知道你说它不是重复的,但你真的尝试过这篇文章中的所有建议吗?我敢肯定至少有一个是你问题的原因。添加相关的gradle文件,以便更好地测量。请参阅@JavaWizard,然后您应该知道已经完成了哪些更新/更改