How To Set Source/Target Level In Maven

Updated: 2020-06-29


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project <your-project-name>: Compilation failure
[ERROR] /path/to/[51,46] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)


If maven-compiler-plugin is not specified, a default will be used(in this case 3.1, which sets -source to 1.5 by default)


Add maven-compiler-plugin to pom.xml


this will set -source and -target of the Java Compiler