api重复引用导致的诡异问题排查

简介: api重复引用导致的诡异问题排查最近一个项目上线前开发环境、测试环境都能正常打包并运行。然而到了准生产环境和生产环境则报一些诡异的错误信息:[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.

api重复引用导致的诡异问题排查

最近一个项目上线前开发环境、测试环境都能正常打包并运行。然而到了准生产环境和生产环境则报一些诡异的错误信息:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project xxx: Compilation failure: Compilation failure:
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/util/ZipRsaCiph.java:[19,15] BASE64Decoder is internal proprietary API and may be removed in a future release
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/util/ZipRsaCiph.java:[19,15] BASE64Decoder is internal proprietary API and may be removed in a future release
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/util/ZipRsaCiph.java:[19,15] BASE64Decoder is internal proprietary API and may be removed in a future release
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/util/ZipRsaCiph.java:[19,15] BASE64Decoder is internal proprietary API and may be removed in a future release
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/util/ZipRsaCiph.java:[64,9] BASE64Decoder is internal proprietary API and may be removed in a future release
[ERROR] /data/release/xxx/xxx/src/main/java/com/xxx/testmodel/aop/Author.java:[95,90] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

咋一看莫名其妙,代码怎么找也找不到问题所在。查看代码修改部分,发现是重新引入了一个新的api。

通过mvn dependency:tree发现,同时引用了 test-api:jar:2.0.0 和 test-api:jar:3.12.0 两个版本的api。

而通过mvn dependency:analyze查看的结果为:

[WARNING] Used undeclared dependencies found:
[WARNING]    com.xxx.auth:xxx-api:jar:2.0.0:compile
[WARNING] Unused declared dependencies found:
[WARNING]    com.xxx.auth:xxx-api:jar:3.12.0:compile

发现并没有引用新的api。
Used undeclared dependencies :指那些在项目中直接使用到的,但没有在POM中配置的依赖。
Unused declared dependencies :供我们参考,这表示那些我们配置了,但并未直接使用的依赖。

后来分析发现是有个第三方 api 引用了相同的api,从而导致这一诡异问题的出现。因而在引用api前可通过:

mvn dependency:treemvn dependency:analyze 看是否存在重复引用的api,如果存在重复引用的情况可将不需要的版本api排除掉即可。

<dependency>
  <groupId>xxx</groupId>
  <artifactId>xxx-api</artifactId>
  <version>1.0</version>
  <exclusions>
    <exclusion>
      <groupId>test</groupId>
      <artifactId>test-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>
相关文章
|
6月前
|
IDE 大数据 Java
大数据问题排查系列 - HDFS FileSystem API 的正确打开方式,你 GET 了吗?
大数据问题排查系列 - HDFS FileSystem API 的正确打开方式,你 GET 了吗?
|
4月前
|
JavaScript 前端开发 算法
Vue 3.0 组合式API 模板引用
Vue 3.0 组合式API 模板引用
17 0
|
9月前
|
PHP
PHP实现自制随机图片API- 调用文件夹和引用网络图片
PHP实现随机图片API- 调用文件夹和引用网络图片
105 0
|
4月前
|
数据采集 Java API
Java 正则表达式【非贪婪匹配、格式验证、反向引用、API】
Java 正则表达式【非贪婪匹配、格式验证、反向引用、API】
|
6月前
|
小程序 Python
python调用win32api 拉起wps问题排查解决方案
python调用win32api 拉起wps问题排查解决方案
|
9月前
|
缓存 负载均衡 监控
php开发中大数据量优化的问题总结(1):smarty循环优化、API掉包丢失数据排查、负载平衡配置
php开发中大数据量优化的问题总结(1):smarty循环优化、API掉包丢失数据排查、负载平衡配置
115 0
|
10月前
|
JSON 人工智能 机器人
Python|Python引用图灵机器人api
Python|Python引用图灵机器人api
115 0
|
10月前
|
测试技术 API CDN
电商API调用问题排查具体步骤!
电商API调用问题排查具体步骤!
|
SQL 存储 JavaScript
Java8 新特性:Lambda 表达式、方法和构造器引用、Stream API、新时间与日期API、注解
Java 8 (又称为 jdk 1.8) 是 Java 语言开发的一个主要版本。 Oracle 公司于 2014 年 3 月 18 日发布 Java 8 ,它支持函数式编程,新的 JavaScript 引擎,新的日期 API,新的Stream API 等等。
409 0
Java8 新特性:Lambda 表达式、方法和构造器引用、Stream API、新时间与日期API、注解
|
编解码 JSON 弹性计算
CDN - API 类型问题排查
浅谈 在调用阿里云 CDN openAPI,经常会出现各种各样的问题排查起来没有好的思路不好分析,今天说下基本的排查思路。 分析 不管调什么 CDN openAPI,无论是控制台还是 SDK 或者用户的脚本,出现问题都可以按照如下思路排查。
CDN - API 类型问题排查