Home >Java >javaTutorial >How to Specify the Java Compiler Version in a pom.xml File?

How to Specify the Java Compiler Version in a pom.xml File?

Barbara Streisand
Barbara StreisandOriginal
2024-11-30 02:28:10616browse

How to Specify the Java Compiler Version in a pom.xml File?

How do you specify the Java compiler version in a pom.xml file?

When encountering compiler errors, such as "generics are not supported in -source 1.3," it's necessary to modify the pom.xml file to specify the correct Java compiler version.

In the provided pom.xml file, the maven-compiler-plugin dependency is already included. To change the compiler version, you can use the following properties:

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

This sets both the source and target compiler versions to 1.8, ensuring your code compiles correctly.

For Maven 3.2.5 or above, these properties can be used to modify the compiler version in the pom.xml file.

The above is the detailed content of How to Specify the Java Compiler Version in a pom.xml File?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn