晨港飞燕刘彦登

编程技术

首页 归档 关于 联系

📢 欢迎来到我的博客!这里主要分享编程技术相关内容,如有问题欢迎留言讨论~

记一次系统的jar包本地化方案

重在思路

 

行内容器环境,tomcat版本是8.5,导致jar包冲突,优先调用了jar包中的方法,致使同名同路径下,改写的类方法失效,报java.lang.NoSuchMethodError错误,删除对应class后需要重新更新jar包到行内maven私服仓库,流程复杂,且不清楚哪些地方依然有重写方法的地方,设置tomcat加载jar包优先级的方式,jar包路径不够灵活,就把关键的几个jar包直接放入lib下,本地调用

本次事件是lib与class中的方法冲突,如果项目中引用相同名不同版本的jar包,如果要确定项目中引用了哪个版本的jar包,只需要看最后打完包后,打进lib下是哪个jar包就可以了

Jar包依赖关系

<groupId>ibp</groupId>                              

<artifactId>ibp-parent、ibp-common-validator、ibp-common-workflow、ibp-coreservice</artifactId>
<version>1.2.1.20180408</version>
<groupId>ibp</groupId>                       



<artifactId>ibp-parent、ibp-api、ibp-common-attach、ibp-common-cache、ibp-common-echarts、ibp-login、ibp-sysmanage</artifactId>  
<version>2.0.1.20200110</version>


<groupId>awp</groupId>                    
<artifactId>awp-parent、awp-common、awp-relation、awp-rpp、awp-search</artifactId>  
<version>1.0-RELEASE</version>


<groupId>grc</groupId>
<artifactId>grc-parent</artifactId>
<version>1.0-SNAPSHOT、grc-xxx</version>8

ibp-sysmanage-2.0.1.20200110

1.在WEB-INF/lib下放入jar包

dd07772df84741ce9a3e4644b43d1035.png

 

 

2.在grc-common模块pom文件修改引入方式,(注意:这种方式,自身依赖传递会失效)

 <dependency>
      <groupId>ibp</groupId>
      <artifactId>ibp-sysmanage</artifactId>
      <version>2.0.1.20200110</version>
      <scope>system</scope>
      <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-sysmanage-2.0.1.20200110.jar</systemPath>
</dependency>

3.经过idea的maven树分析,ibp-sysmanage自身有效依赖,补充如下

051f9485c385446a8faeea15ef6dabec.png

 

<!--***代替ibp-sysmanage补充jar包 start****-->

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-api</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-cache</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-echarts</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-attach</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
   <groupId>dom4j</groupId>
   <artifactId>dom4j</artifactId>
   <version>1.6.1</version>
</dependency>

<!--***代替ibp-sysmanage补充jar包 end****-->

 

 

4.查找引用ibp-sysmanage的jar包进行排除,

ibp-common-workflow和awp-common在grc-common模块引用

bb3bbbb8587748368d9801d20efe0a20.png

 29c37918f9a74c2e8ef5839061008da8.png

 

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-workflow</artifactId>
   <version>${ibp.version}</version>
 <exclusions>

...
    <exclusion>
      <groupId>ibp</groupId>
      <artifactId>ibp-sysmanage</artifactId>
    </exclusion>
 </exclusions>
</dependency>



<dependency>
   <groupId>awp</groupId>
   <artifactId>awp-common</artifactId>
   <version>1.0-RELEASE</version>
   <exclusions>
      <exclusion>
         <groupId>ibp</groupId>
         <artifactId>ibp-sysmanage</artifactId>
      </exclusion>
   </exclusions>
</dependency>



因为grc-common已经引入awp-common,可以排除了awp-relation下的awp-common包,grc-bpa模块中引用了awp-relation

<dependency>
   <groupId>awp</groupId>
   <artifactId>awp-relation</artifactId>
   <version>1.0-RELEASE</version>
      <exclusions>
      <exclusion>
         <groupId>awp</groupId>
         <artifactId>awp-common</artifactId>
      </exclusion>
   </exclusions>
</dependency>

 

 

ibp-common-workflow-1.2.1.20180408

1.在WEB-INF/lib下放入jar包

54a9bded5a61445cb77e2f9e8708a939.png

 

 

2.在grc-common模块pom文件修改引入方式,(注意:这种方式,自身依赖传递会失效)

 

<dependency>
      <groupId>ibp</groupId>
      <artifactId>ibp-common-workflow</artifactId>
      <version>1.2.1.20180408</version>
      <scope>system</scope>
      <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-common-workflow-1.2.1.20180408.jar</systemPath>
</dependency>

 

3.经过idea的maven树分析,ibp-common-workflow自身有效依赖,补充如下

d78ba4c18c3546279a242b87dab24467.png

 

<!--***代替ibp-common-workflow补充jar包 start***-->
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-engine</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-spring</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-rest</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-modeler</artifactId>
   <version>5.17.0</version>
</dependency>
<!--***代替ibp-common-workflow补充jar包 end***-->

 

ibp-coreservice-1.2.1.20180408

 

1.在WEB-INF/lib下放入jar包

c55426c0e43c4961a8507c587e214e4e.png

 

 

2.在grc-common模块pom文件修改引入方式,(注意:这种方式,自身依赖传递会失效)

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-coreservice</artifactId>
   <version>1.2.1.20180408</version>
   <scope>system</scope>
   <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-coreservice-1.2.1.20180408.jar</systemPath>
</dependency>

3.经过idea的maven树分析,ibp-coreservice自身有效依赖,补充如下(好像不加也能启动)

 

a6df9323031a439bb08c5d60e1cf1a53.png

 

ccc22013fe514800a28c0f207cae1fef.png

 

<!--***代替ibp-coreservice补充jar包 start***-->
<dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
</dependency>
<dependency>
   <groupId>com.github.jsqlparser</groupId>
   <artifactId>jsqlparser</artifactId>
</dependency>
<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
</dependency>
<dependency>
   <groupId>org.jdom</groupId>
   <artifactId>jdom</artifactId>
</dependency>
<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
</dependency>
<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
</dependency>
<dependency>
   <groupId>org.apache.ant</groupId>
   <artifactId>ant</artifactId>
</dependency>
<dependency>
   <groupId>commons-dbutils</groupId>
   <artifactId>commons-dbutils</artifactId>
</dependency>
<dependency>
   <groupId>commons-collections</groupId>
   <artifactId>commons-collections</artifactId>
   <version>3.2.1</version>
</dependency>
<!--***代替ibp-coreservice补充jar包 end***-->

其他jar包

 

ibp-login:2.0.1.20200110

ibp-common-validator:1.2.1.20180408,

ibp-common-echarts:2.0.1.20200110

ibp-common-attach:2.0.1.20200110

此版本的自身依赖全部为无效状态

ibp-api:2.0.1.20200110 有效依赖

<!--***代替ibp-api补充jar包 start***-->
<dependency>
   <groupId>org.javassist</groupId>
   <artifactId>javassist</artifactId>
</dependency>
<dependency>
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpclient</artifactId>
</dependency>
<dependency>
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpcore</artifactId>
</dependency>
<dependency>
   <groupId>commons-net</groupId>
   <artifactId>commons-net</artifactId>
</dependency>
<dependency>
   <groupId>com.jcraft</groupId>
   <artifactId>jsch</artifactId>
</dependency>
<!--***代替ibp-api补充jar包 end***-->

ibp-common-cache:2.0.1.20200110 有效依赖

<!--***代替ibp-common-cache:2.0.1.20200110补充jar包 start***-->
<dependency>
   <groupId>redis.clients</groupId>
   <artifactId>jedis</artifactId>
   <type>jar</type>
   <version>2.7.3</version>
</dependency>
<dependency>
   <groupId>de.ruedigermoeller</groupId>
   <artifactId>fst</artifactId>
   <version>1.58</version>
</dependency>
<dependency>
   <groupId>com.esotericsoftware</groupId>
   <artifactId>kryo-shaded</artifactId>
   <version>3.0.0</version>
</dependency>
<dependency>
   <groupId>com.googlecode.ehcache-spring-annotations</groupId>
   <artifactId>ehcache-spring-annotations</artifactId>
   <version>1.1.2</version>
   <type>jar</type>
   <scope>compile</scope>
</dependency>
<dependency>
   <groupId>cglib</groupId>
   <artifactId>cglib</artifactId>
</dependency>
<dependency>
   <groupId>com.ist</groupId>
   <artifactId>commons-pool2</artifactId>
</dependency>
<!--***代替ibp-common-cache:2.0.1.20200110补充jar包 end***-->

 

 

完整配置

不包含其他jar包

启动成功,仓库不再下载相应jar包

 

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-sysmanage</artifactId>
   <version>2.0.1.20200110</version>
   <scope>system</scope>
   <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-sysmanage-2.0.1.20200110.jar</systemPath>
</dependency>

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-workflow</artifactId>
   <version>1.2.1.20180408</version>
   <scope>system</scope>
   <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-common-workflow-1.2.1.20180408.jar</systemPath>
</dependency>

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-coreservice</artifactId>
   <version>1.2.1.20180408</version>
   <scope>system</scope>
   <systemPath>${project.basedir}/../grc/src/main/webapp/WEB-INF/lib/ibp-coreservice-1.2.1.20180408.jar</systemPath>
</dependency>

<dependency>
   <groupId>awp</groupId>
   <artifactId>awp-common</artifactId>
   <version>1.0-RELEASE</version>
   <exclusions>
      <exclusion>
         <groupId>ibp</groupId>
         <artifactId>ibp-sysmanage</artifactId>
      </exclusion>
   </exclusions>
</dependency>

<!--***代替ibp-common-workflow补充jar包 start***-->
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-engine</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-spring</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-rest</artifactId>
   <version>5.17.0</version>
</dependency>
<dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-modeler</artifactId>
   <version>5.17.0</version>
</dependency>
<!--***代替ibp-common-workflow补充jar包 end***-->

<!--***代替ibp-sysmanage补充jar包 start****-->

<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-api</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-cache</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-echarts</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>ibp</groupId>
   <artifactId>ibp-common-attach</artifactId>
   <version>2.0.1.20200110</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
   <groupId>dom4j</groupId>
   <artifactId>dom4j</artifactId>
   <version>1.6.1</version>
</dependency>
<!--***代替ibp-sysmanage补充jar包 end****-->

<!--***代替ibp-coreservice补充jar包 start***-->
  <dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
</dependency>
<dependency>
   <groupId>com.github.jsqlparser</groupId>
   <artifactId>jsqlparser</artifactId>
</dependency>
<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
</dependency>
<dependency>
   <groupId>org.jdom</groupId>
   <artifactId>jdom</artifactId>
</dependency>
<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
</dependency>
<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
</dependency>
<dependency>
   <groupId>org.apache.ant</groupId>
   <artifactId>ant</artifactId>
</dependency>
<dependency>
   <groupId>commons-dbutils</groupId>
   <artifactId>commons-dbutils</artifactId>
</dependency>
<dependency>
   <groupId>commons-collections</groupId>
   <artifactId>commons-collections</artifactId>
   <version>3.2.1</version>
</dependency>
<!--***代替ibp-coreservice补充jar包 end***-->

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2023-06-28 15:21  晨港飞燕刘彦登  阅读(34)  评论(0)    收藏  举报  来源