简体   繁体   中英

maven version error - maven ignores specified version

Im trying to build use maven from the terminal, and am getting the following error:

[ERROR] (use -source 5 or higher to enable annotations)

The strange thing is, in my pom I have the following:

    <properties>
...
        <java.version>1.7</java.version>
...
    </properties>

and

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.2</version>
      <configuration>
      <source>${java.version}</source>
      <target>${java.version}</target>
      </configuration>
</plugin>

When I run maven install from within eclipse it works.

When I run mvn --version from the terminal, here is the output:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_72, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-24-generic", arch: "amd64", family: "unix"

I noticed too, that when running from the terminal, there is the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project

So, for some strange reason it is using an older version of the compiler plugin when running from the terminal.

Anyone know why this error is occurring, and how to fix it?

Found the answer on Maven plugin version in pom (seemingly) ignored

Using the following fixed it:

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.1</version>
    </plugin>
  </plugins>
</pluginManagement>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM