我正在尝试从Gradle移植到Maven,并从JDK 9更改为JDK 12。
我从Maven的一个项目开始,但是丢失了源代码(是的,我知道应该做个备份),无论如何,我有点菜鸟,但是我想我知道这样做(可能没有),因为我的代码似乎在带有JDK 9的原始Gradle项目中完美运行,所以我的代码似乎没有问题,要迁移代码,我只是将src文件夹中的文件移动到了新Maven的src文件夹中从Gradle项目到Maven项目的pom.xml,以及在build.gradle中具有的依赖项。我正在使用IntelliJ IDEA 2019.1(如果相关的话)
编译器中错误所引用的类是这个:
package com.codingneko.Commands;
import java.awt.Color;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
public class Commands {
static EmbedBuilder eb = new EmbedBuilder();
public static void buildEmbed() {
eb.setColor(Color.green);
eb.addField("Help", "Shows this embed DUH?", true);
CatFacts.addField();
CustomColours.addField();
DoOrDoes.addField();
Kiss.addField();
Osu.addField();
Pat.addField();
Ping.addField();
Roll.addField();
Gelbooru.addField();
}
public static void run(GuildMessageReceivedEvent e) {
e.getChannel().sendMessage(eb.build()).queue();
}
}
尤其是e.getChannel().sendMessage(eb.build()).queue();
行
IDE不会指出代码中的任何错误或任何引用错误或类似的东西(没有红色的摆动行),但是当我尝试运行我的main时,它会显示以下内容:
Error:(28, 47) java: cannot access java.util.function.Consumer
class file for java.util.function.Consumer not found
这是运行maven install的结果
"C:\Program Files\Java\jdk-9.0.1\bin\java.exe" -Dmaven.multiModuleProjectDirectory=F:\Projects\Java\hibiki "-Dmaven.home=E:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=E:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:E:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\lib\idea_rt.jar=51456:E:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\bin" -Dfile.encoding=UTF-8 -classpath "E:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version2019.1 install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.codingneko:hibiki:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 12, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hibiki 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hibiki ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hibiki ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 21 source files to F:\Projects\Java\hibiki\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hibiki ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory F:\Projects\Java\hibiki\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hibiki ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hibiki ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hibiki ---
[INFO] Building jar: F:\Projects\Java\hibiki\target\hibiki-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hibiki ---
[INFO] Installing F:\Projects\Java\hibiki\target\hibiki-1.0-SNAPSHOT.jar to C:\Users\Ivo Carbajo\.m2\repository\com\codingneko\hibiki\1.0-SNAPSHOT\hibiki-1.0-SNAPSHOT.jar
[INFO] Installing F:\Projects\Java\hibiki\pom.xml to C:\Users\Ivo Carbajo\.m2\repository\com\codingneko\hibiki\1.0-SNAPSHOT\hibiki-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.267 s
[INFO] Finished at: 2019-04-06T20:33:44+02:00
[INFO] Final Memory: 17M/56M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0