Best Practice
Defining properties related to Java version and encoding
Properties
Mentioning below properties are considered best practices for a Spring project's pom.xml
java.version
:
java.version
:Purpose: Specifies the version of Java that the project is using.
Usage: This property is often used in plugins and other configurations to ensure that the project is built and runs with the specified Java version.
Example:
<java.version>17</java.version>
maven.compiler.source
:
maven.compiler.source
:Purpose: Sets the version of the source code. It tells the Maven Compiler Plugin which version of the Java language features to use.
Usage: Ensures that the compiler uses the correct Java version for source files.
Example:
<maven.compiler.source>17</maven.compiler.source>
maven.compiler.target
:
maven.compiler.target
:Purpose: Specifies the version of the JVM for the compiled bytecode.
Usage: Ensures that the compiled bytecode is compatible with the specified version of the JVM.
Example:
<maven.compiler.target>17</maven.compiler.target>
project.build.sourceEncoding
:
project.build.sourceEncoding
:Purpose: Defines the character encoding for the source files.
Usage: Ensures that all source files are read and compiled using the specified encoding. UTF-8 is typically used because it can represent any character in the Unicode standard.
Example:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
project.reporting.outputEncoding
:
project.reporting.outputEncoding
:Purpose: Sets the character encoding for the output of reporting tasks, such as generated reports and documentation.
Usage: Ensures that generated reports are encoded correctly, preventing issues with special characters.
Example:
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Example
Last updated
Was this helpful?