maven does not compile in java 1.6

后端 未结 3 1908
挽巷
挽巷 2020-12-22 03:45

how to force maven to compile 1.6 compatible source

i made web-app project with maven in eclipse. change web.xml to use 3.0 version -> then update configuration and

相关标签:
3条回答
  • 2020-12-22 04:24

    Just for clarification :

    In your project POM, you don't actually write all your configuraton, but override (and eventually add features to) the default configuration.

    "Effective POM" in Eclipse shows you the result of it, so indeed this is not editable.

    However, if you add some configuration in your POM (like waht is proposed in the other answers), it will override the default settings. It will be used as is, and will shown in the "Effective POM".

    0 讨论(0)
  • 2020-12-22 04:25

    You have it there. Just put 1.6 instead of 1.7:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    

    see: http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

    I would also avoid additional configuration if not needed.

    0 讨论(0)
  • 2020-12-22 04:34

    EDIT:

    Just use instead of 1.7 java 1.6.

    EDIT2:

    Your version:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <showDeprecation>true</showDeprecation>
          <showWarnings>true</showWarnings>
          <executable>${env.JAVA_HOME_7}/bin/javac</executable>
          <fork>true</fork>
        </configuration>
    </plugin>
    

    Should be:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <showDeprecation>true</showDeprecation>
          <showWarnings>true</showWarnings>
          <executable>${env.JAVA_HOME_7}/bin/javac</executable>
          <fork>true</fork>
        </configuration>
    </plugin>
    
    0 讨论(0)
提交回复
热议问题