How to configure the java version?

Asked

Viewed 554 times

3

Following the step by step of the lesson 1.3 Introduction to Maven, we have the following code (replace square brackets for braquets):

[modelVersion]4.0.0[/modelVersion]
  [groupId]com.algaworks[/groupId]
  [artifactId]comecando-primefaces[/artifactId]
  [version]0.0.1-SNAPSHOT[/version]
  [packaging]war[/packaging]

  [properties]
    [project.buid.sourceEncoding]UTF-8[/project.buid.sourceEncoding]
  [/properties]

  [build]
    [plugins]
        [plugin]
            [artifactId]maven-compiler-plugin[/artifactId]
            [version]3.1[/version]
            [configuration]
                [source]1.8[/source]
                [target]1.8[/target]
            [/configuration]
        [/plugin]
    [/plugins]
  [/build]

[/project]

The java version configuration is at 1.8. However, the official configuration is still 1.5. I have used Maven->Update Project->Ok, which in the video went well, but in my eclipse not its right, continued 1.5.

In addition, the Eclipse points to an error on line 6 ([version]0.0.1-SNAPSHOT[/version]). Force update of Maven did not solve the problem, contrary to what the teacher said in the video.

How to solve?

  • 1

    put the normal tags, so we can make a more fluid reading.

  • Your eclipse must be forcing the compilation into 1.5 do this : properties > java compiler > compiler complience level > 1.8

1 answer

0

The tag <source>1.8</source> is not in the right place.

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>smochin</groupId>
<artifactId>InstagramAPI</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-client</artifactId>
        <version>9.3.1.v20150714</version>
    </dependency>
</dependencies>

See, is in properties/source and its configuration is in build/plugins/plugin/configuration/source.

Valley to target also.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.