最近项目中,I商机用jdk1.7,而ltc用jdk1.8,所以提供给他们的api都要不同的版本
- 修改pom.xml配置
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>${jar.source}</source>
<target>${jar.target}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- 这里省略属性 -->
</properties>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<jar.source>1.8</jar.source>
<jar.target>1.8</jar.target>
</properties>
</profile>
<profile>
<id>jdk17</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>jdk17</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<jar.source>1.7</jar.source>
<jar.target>1.7</jar.target>
</properties>
</profile>
</profiles>
- 执行打包命令
mvn clean package -P jdk17
- 引入jar包时作以下修改
<dependency>
<groupId>com.meicloud.meiqing</groupId>
<artifactId>workflow-api</artifactId>
<version>1.1.0-SNAPSHOT</version>
<classifier>jdk17</classifier>
</dependency>
至此,jdk1.7的api打包成功