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

proguard Note: duplicate definition of library class [javax.annotation.PostConstruct]

我尝试在 Spring 启动应用程序上启动 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.

为什么会出现此错误,我该如何解决?

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

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

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

  1. 如果您添加混淆器选项-printconfiguration configuration.txt,您将看到所有添加的混淆器。
  2. 根据您从上述步骤中收到的信息,您可以更正相同的

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

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

请查看 this 问题,详细了解您现在面临的情况。