-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
内嵌 jsqlparser 以规避版本冲突 #784
Conversation
afac998
to
8c0bb2d
Compare
使用 独立发布一个 |
使用如下的配置项可以在生成原版 <createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>standalone</shadedClassifierName> |
@pagehelper 我写了一个同时内嵌 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-standalone</artifactId>
<version>6.0.0</version>
<dependencies>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<artifactSet>
<includes>
<include>com.github.pagehelper:*</include>
<include>com.github.jsqlparser:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
<filter>
<artifact>com.github.jsqlparser:*</artifact>
<excludes>
<exclude>META-INF/maven/**</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>net.sf.jsqlparser</pattern>
<shadedPattern>com.github.pagehelper.jsqlparser</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
|
用profile就行,第一次deploy走默认,第二次deploy指定shade方式,不需要一次构建两个。 |
这种方式使用同一个pom.xml确实有问题,简单考虑只能通过版本号额外的后缀来区分了 |
项目中有时会引用
jsqlparser
,但是由于jsqlparser
各版本之间总是会有兼容性问题,经常会面临版本冲突的问题。所以,我建议
pagehelper
将自己所使用的jsqlparser
内嵌进 jar 包以规避此类问题。maven-shade-plugin
可以在打包时将所有对net.sf.jsqlparser
的引用重定向到com.github.pagehelper.jsqlparser
,这样这部份代码将只被pagehelper
使用,而不影响外部项目。不管pagehelper
使用什么版本的jsqlparser
,外部项目使用什么版本的jsqlparser
都不会互相干扰。同时maven-shade-plugin
可以生成一个新的不包含对jsqlparser
依赖的pom.xml
,用于项目发布。