try-with-resources is not supported
Some time we face issues while building java project with maven with error below:
This problem can be resolved by providing the maven compile plugin in pom.xml.
<build>
Some time we face issues while building java project with maven with error below:
- try-with-resources is not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable try-with-resources)
- diamond operator is not supported in -source 1.5[ERROR] (use -source 7 or higher to enable diamond operator)
This problem can be resolved by providing the maven compile plugin in pom.xml.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Here I have given the compile Jdk 1.8 as source and target. You can specify this version as per your requirement.
Source of this information is available at maven docs.
No comments:
Post a Comment