I use JOOQ to implement MySQL DAO layer. And my part of pom.xml is as below,
<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>
<build>
<plugins>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.9.1</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies />
<configuration>
<jdbc>
<driver>${jdbc.driver}</driver>
<url>${jdbc.url}</url>
<user>${jdbc.user}</user>
<password>${jdbc.password}</password>
</jdbc>
<generator>
<database>
</database>
<target>
</target>
</generator>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass />
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I got the jar file by mvn package
. But when I run the jar file, the error occurs:
java.lang.UnsupportedClassVersionError: org/jooq/Table : Unsupported major.minor version 52.0
I learned that I could update my running JDK version to a higher one, or compile the jooq generated classes with a lower version. Here I have to choose the latter method. But the result didn't meet my expectation after I set the target of maven-compiler-plugin
to 1.7. I am confused since I still get this error. So how can I achieve my goal?
The jOOQ Open Source Edition version 3.7+ requires Java 8 to run. If you need Java 7 support, that is provided by the jOOQ Professional Edition and jOOQ Enterprise Edition. See version support here: https://www.jooq.org/download/versions
In particular, you have defined Maven properties that point to the JDK 8:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
But you're not using them in your compiler plugin configuration. You should switch this:
<source>1.7</source>
<target>1.7</target>
To this:
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>