2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

Configure maven to user java 8 as compiler

I want to configure java 8 in pom.xml so that the build will be compiled with java 8.

userimage

try below configuration to make sure the build compiled with java 8:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <packaging>war</packaging>
   <version>1.0-SNAPSHOT</version>
   <properties>
      <java-version>1.8</java-version>
   </properties>
   <build>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>${java-version}</source>
               <target>${java-version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>
Answer is