Java-maven编译报错diamond operator is not supported in -source 1.5

来自三线的随记
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 201 source files to /workspace/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /workspace/src/main/java/com/watsons/rts/commons/utils/shardingsphere/alg/TableRangeShardingAlgorithm.java:[21,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /workspace/src/main/java/com/watsons/rts/commons/utils/container/JarLoader.java:[108,58] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /workspace/src/main/java/com/watsons/rts/commons/utils/shardingsphere/alg/RealtimeStockTableRangeShardingAlgorithm.java:[20,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /workspace/src/main/java/com/watsons/rts/commons/utils/shardingsphere/alg/TableComplexShardingAlgorithm.java:[23,51] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[INFO] 4 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.016 s
[INFO] Finished at: 2020-08-27T07:19:43Z
[INFO] ----------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project watsons-rts-commons: Compilation failure: Compilation failure: 
[ERROR] /workspace/src/main/java/com/watsons/rts/commons/utils/shardingsphere/alg/TableRangeShardingAlgorithm.java:[21,52] diamond operator is not supported in -source 1.5

solution

添加到pom.xml

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <java.version>1.8</java.version>
  </properties>