maven-指定java编译器subversion
运行Maven Update时,Maven会更改我的Eclipse项目的jdk版本。我在这里看到许多线程询问如何为Maven指定Java版本,这很简单:maven-指定java编译器subversion,java,eclipse,maven,version,Java,Eclipse,Maven,Version,运行Maven Update时,Maven会更改我的Eclipse项目的jdk版本。我在这里看到许多线程询问如何为Maven指定Java版本,这很简单: <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
1.8
1.8
我已经安装了JDK1.8.0_181和1.8.0_172。如果我想继续在我的系统中使用172,但我想使用181进行编译,我怎么能告诉maven呢?我可以只指定主版本(1.8)而不指定其他次要版本号吗?您提到的数字与您使用的实际JDK版本无关。这通常通过
JAVA\u HOME
设置。您还可以在Maven编译器插件中明确地设置它
您提到的属性设置编译器的行为。例如,即使使用JDK1.8.x,您也可以使用1.7进行编译(而不是使用JDK1.7.x的1.8)。您可以通过将路径设置为要使用的javac版本来指定maven编译器使用的路径
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
org.apache.maven.plugins