I am setting this in the pom.xml file:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</build>
When I open the .jar file and check the .class file with javap -v, it outputs "major version: 52" which corresponds to 1.8, so I see it did not respect my configuration.
I have a dependency on javax.persistence:
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
If I remove this dependency, the javap -v outputs "major version: 51" which is the target I want.
But I need the dependency.
Is it possible to target 1.7 with the javax.persistence dependency? How?
I was expecting compilation errors if it could not target Java 1.7 as I configured.
I am using IntelliJ IDEA.
Thanks.
Did you try this?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
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.