My environment java version is jdk8,Now I want use Maven command mvn package
to compile some project.How to specify java version(like java11) to compile it whitout change environment path,because java version is a dynamic arguments in my process
In pom.xml you can define the version of JDK
Like
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.1</spring-cloud.version>
</properties>
Compiling Sources Using A Different JDK
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>11</compilerVersion>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Well the side effect is we have to edit the pom.xml file.
pom-java11.xml
, pom-java17.xml
mvn -f <other pom file>
for your task, like mvn -f pom-java11.xml...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.