我使用 JOOQ 来实现 MySQL DAO 层。我的 pom.xml 部分如下,
<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>
我得到了 jar 文件mvn package
。但是当我运行jar文件时,出现错误:
java.lang.UnsupportedClassVersionError: org/jooq/Table : Unsupported major.minor version 52.0
我了解到我可以将正在运行的 JDK 版本更新到更高版本,或者使用更低版本编译 jooq 生成的类。这里我不得不选择后一种方法。但是我把目标定maven-compiler-plugin
为1.7后,结果并没有达到我的预期。我很困惑,因为我仍然收到此错误。那么我怎样才能实现我的目标呢?