`@PreAuthorize` with spring-native triggers packaging error: `repeated interface: org.springframework.aop.SpringProxy`

`@PreAuthorize` with spring-native triggers packaging error: `repeated interface: org.springframework.aop.SpringProxy`

我正在尝试在 Maven multi-module project.

中为 spring-boot 应用程序构建本机映像

当我用 @PreAuthorize 修饰 @Controller 方法后,本机图像生成失败并显示以下消息。

根据 spring-native 样本,我在应用程序 class,但这没有什么区别。

错误:

[INFO]     [creator]     Error: Error parsing dynamic proxy configuration in file:/workspace/META-INF/native-image/org.springframework.aot/spring-aot/proxy-config.json:
[INFO]     [creator]     java.lang.IllegalArgumentException: repeated interface: org.springframework.aop.SpringProxy
[INFO]     [creator]     Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option DynamicProxyConfigurationResources.
[INFO]     [creator]     Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[INFO]     [creator]     Error: Image build request failed with exit status 1
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to contribute native-image layer
[INFO]     [creator]     error running build
[INFO]     [creator]     exit status 1
[INFO]     [creator]     ERROR: failed to build: exit status 1

知道为什么吗?

关于这个错误我想出了两件事:

  1. 一旦 @PreAuthorize 以 class 成员(而非接口)为目标,配置必须为此 class
  2. 提供 @AotProxyHint(targetClass = ..., proxyFeatures = ProxyBits.IS_STATIC)
  3. Windows 上存在关于 spring-native issues
  4. 中声明的错误