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
Release: 2024-11-30 02:28:10
Original
608 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template