proguard 注意:库类的重复定义 [javax.annotation.PostConstruct]

Posted

技术标签:

【中文标题】proguard 注意:库类的重复定义 [javax.annotation.PostConstruct]【英文标题】:proguard Note: duplicate definition of library class [javax.annotation.PostConstruct] 【发布时间】:2019-01-24 10:31:18 【问题描述】:

我尝试在 Spring Boot App 上启动 ProGuard 并得到错误:

  [proguard] Reading library jar [C:\Program Files\Java\jdk1.8.0_151\jre\lib\rt.jar]
     [proguard] Note: duplicate definition of library class [javax.annotation.Generated]
     [proguard] Note: duplicate definition of library class [javax.annotation.PostConstruct]
     [proguard] Note: duplicate definition of library class [javax.annotation.PreDestroy]
     [proguard] Note: duplicate definition of library class [javax.annotation.Resource$AuthenticationType]
     [proguard] Note: duplicate definition of library class [javax.annotation.Resource]
     [proguard] Note: duplicate definition of library class [javax.annotation.Resources]
     [proguard] Note: there were 8 duplicate class definitions.
     [proguard]       (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
     [proguard] Warning: there were 2 classes in incorrectly named files.
     [proguard]          You should make sure all file names correspond to their class names.
     [proguard]          The directory hierarchies must correspond to the package hierarchies.
     [proguard]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
     [proguard]          If you don't mind the mentioned classes not being written out,
     [proguard]          you could try your luck using the '-ignorewarnings' option.
     [proguard] Error: Please correct the above warnings first.

为什么我会收到此错误,我该如何解决?

【问题讨论】:

【参考方案1】:

您可以执行以下操作来摆脱这种情况:

    如果您添加一个 proguard 选项 -printconfiguration configuration.txt,您将看到所有添加的 proguard。 根据您从上述步骤中收到的信息,您可以更正相同的内容

您可以使用以下选项停止看到这些警告消息:文档here

-dontwarn javax.annotation.*
-dontnote javax.annotation.*

请查看this 问题以了解有关您现在所面临情况的更多详细信息。

【讨论】:

【参考方案2】:

尝试忽略类-dontnote javax.annotation.*

阅读更多: https://www.guardsquare.com/en/products/proguard/manual/troubleshooting#duplicateclass

【讨论】:

以上是关于proguard 注意:库类的重复定义 [javax.annotation.PostConstruct]的主要内容,如果未能解决你的问题,请参考以下文章

Gradle 在使用 Proguard 编译发布版本时无法找到一些引用和库类

Proguard:有 210 个重复的类定义?

带有重复 Zip 输入错误的 Proguard

收到太多 Proguard 警告

StringUtils 或任何库类方法来保留分隔符[重复]

Proguard 关于重复类定义的警告,但不打印出重复的类