要么我像地狱一样愚蠢,错过了很明显的东西,要么我的Rasberry Pi做得很奇怪。我只是在尝试编译一个简单的Java项目,尽管我安装了Java 9,但Maven一直告诉我B[n].x
:
struct b
我还检查了java和javac的路径,但两者似乎也是正确的:
Fatal error compiling: invalid target release: 9.0
pi@Harald:~ $ mvn -v
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 9-Raspbian, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-9-openjdk-armhf
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "4.14.79-v7+", arch: "arm", family: "unix"
我想念什么?
答案 0 :(得分:0)
JAVA_HOME
设置为JDK 9。maven-compiler-plugin
源/目标/发行版属性:<properties>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<maven.compiler.release>9</maven.compiler.release>
</properties>
maven-compiler-plugin
和maven-toolchains-plugin
:<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<configuration>
<toolchains>
<jdk>
<version>1.9</version>
<vendor>oracle</vendor>
</jdk>
</toolchains>
</configuration>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
注释:
~/.m2/toolchains.xml
并添加以下内容:<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.9</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>/path/to/your/jdk-9</jdkHome>
</configuration>
</toolchain>
</toolchains>
pom.xml
:第一个符号链接/ bin / javac9到
/ opt / jdk-9 / bin / javac和/ opt / jdk-9到JDK 9版本
当前正在使用。然后尝试以下命令:mvn -Dmaven.compiler.fork -Dmaven.compiler.executable=javac9 install