spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.22k stars 786 forks source link

Error compiling aot when FeignClient contextId has value #796

Closed admintertar closed 1 year ago

admintertar commented 1 year ago

Error compiling aot when FeignClient contextId has value

2022.0.0-RC3 sping-boot3.0 image

image

image

Compilation succeeds when I comment out the contextId

admintertar commented 1 year ago

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project test: Unable to compile generated source [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration is protected access in org.springframework.cloud.openfeign.FeignClientsConfiguration /Users/ping/work-space/com.waitylyyou/test/target/spring-aot/ main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/shushang/x/booking/api/ILongtermBookingOrderApiBeanDefinitions.java 192:52 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration is protected access in org.springframework.cloud.openfeign.FeignClientsConfiguration /Users/ping/work-space/com.waitylyyou/test/target/spring-aot/ main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/shushang/x/booking/api/ILongtermBookingOrderApiBeanDefinitions.java 194:67 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration is protected access in org.springframework.cloud.openfeign.FeignClientsConfiguration /Users/ping/work-space/com.waitylyyou/test/target/spring-aot/ main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/shushang/x/booking/api/ILongtermBookingOrderApiBeanDefinitions.java 202:92 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration is protected in org.springframework.cloud.openfeign.FeignClientsConfiguration Visit /Users/ping/work-space/com.waitylyyou/test/target/spring-aot/main /sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/shushang/x/booking/api/ILongtermBookingOrderApiBeanDefinitions.java 203:121

ccwxl commented 1 year ago

github compiling is ok. Should be plugin or other issues

admintertar commented 1 year ago

@siaron I use mvn -Pnative native:compile

ccwxl commented 1 year ago

@siaron I use mvn -Pnative native:compile

add param -x look log.

admintertar commented 1 year ago

@siaron I use mvn -Pnative native:compile

add param -x look log.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project test: Unable to compile generated source [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 192:52 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 194:67 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 202:92 [ERROR] org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 203:121 [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project test: Unable to compile generated source org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 192:52 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 194:67 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 202:92 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 203:121 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to compile generated source org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 192:52 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 194:67 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 202:92 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 203:121 at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:107) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.IllegalStateException: Unable to compile generated source org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 192:52 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 194:67 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 202:92 org.springframework.cloud.openfeign.FeignClientsConfiguration.DefaultFeignBuilderConfiguration 在 org.springframework.cloud.openfeign.FeignClientsConfiguration 中是 protected 访问控制 /Users/ping/work-space/com.waitylyou/test/target/spring-aot/main/sources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java 203:121 at org.springframework.boot.maven.AbstractAotMojo.compileSourceFiles (AbstractAotMojo.java:154) at org.springframework.boot.maven.ProcessAotMojo.executeAot (ProcessAotMojo.java:95) at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:104) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) [ERROR] [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/MojoExecutionException ➜ test

admintertar commented 1 year ago

@siaron I use mvn -Pnative native:compile

add param -x look log.

Can you increase the contextid through compilation?

ccwxl commented 1 year ago

https://github.com/siaron/spring-cloud-kubernetes-microservices-toolkit

ccwxl commented 1 year ago

@siaron I use mvn -Pnative native:compile

add param -x look log.

Can you increase the contextid through compilation?

yes . example: example-service-account

admintertar commented 1 year ago

I see you are using gradle I am using maven I will try to use gradle first

admintertar commented 1 year ago

@siaron I use mvn -Pnative native:compile

add param -x look log.

Can you increase the contextid through compilation?

yes . example: example-service-account

I have the same situation under gradle

admintertar commented 1 year ago

Task :processAot

. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v3.0.0)

2022-12-06T18:03:46.289+08:00 INFO 36546 --- [ main] com.waitylyou.test.TestApplication : Starting TestApplication using Java 17.0.5 with PID 36546 (/Users/ping/work-space/com.waitylyou/test/build/classes/java/main started by ping in /Users/ping/work-space/com.waitylyou/test) 2022-12-06T18:03:46.294+08:00 INFO 36546 --- [ main] com.waitylyou.test.TestApplication : No active profile set, falling back to 1 default profile: "default" 2022-12-06T18:03:47.067+08:00 INFO 36546 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode. 2022-12-06T18:03:47.084+08:00 INFO 36546 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 14 ms. Found 0 JDBC repository interfaces. 2022-12-06T18:03:47.294+08:00 INFO 36546 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=7fc96b25-c9ef-3301-8e22-87f07cf5e34e

Task :compileAotJava FAILED /Users/ping/work-space/com.waitylyou/test/build/generated/aotSources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java:192: 错误: DefaultFeignBuilderConfiguration 在 FeignClientsConfiguration 中是 protected 访问控制 Class<?> beanType = FeignClientsConfiguration.DefaultFeignBuilderConfiguration.class; ^ /Users/ping/work-space/com.waitylyou/test/build/generated/aotSources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java:194: 错误: DefaultFeignBuilderConfiguration 在 FeignClientsConfiguration 中是 protected 访问控制 beanDefinition.setInstanceSupplier(FeignClientsConfiguration.DefaultFeignBuilderConfiguration::new); ^ /Users/ping/work-space/com.waitylyou/test/build/generated/aotSources/org/springframework/cloud/openfeign/FeignClientsConfigurationFeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java:202: 错误: DefaultFeignBuilderConfiguration 在 FeignClientsConfiguration 中是 protected 访问控制 return BeanInstanceSupplier.forFactoryMethod(FeignClientsConfiguration.DefaultFeignBuilderConfiguration.class, "feignBuilder", Retryer.class) ^ /Users/ping/work-space/com.waitylyou/test/build/generated/aotSources/org/springframework/cloud/openfeign/FeignClientsConfiguration__FeignClientFactory_com/waitylyou/test/feign/TestFeignBeanDefinitions.java:203: 错误: DefaultFeignBuilderConfiguration 在 FeignClientsConfiguration 中是 protected 访问控制 .withGenerator((registeredBean, args) -> registeredBean.getBeanFactory().getBean(FeignClientsConfiguration.DefaultFeignBuilderConfiguration.class).feignBuilder(args.get(0))); ^ 4 个错误

FAILURE: Build failed with an exception.

admintertar commented 1 year ago

https://github.com/admintertar/feign-aot-test/tree/main

ccwxl commented 1 year ago

contextId can only be a string. Cannot be in package format. The Spring AoT code generator handles errors

ccwxl commented 1 year ago

forexample: contextId="TestFeign"

admintertar commented 1 year ago

contextId can only be a string. Cannot be in package format. The Spring AoT code generator handles errors

yes

OlgaMaciaszek commented 1 year ago

Hello @admintertar. Have you tried switching the contextId to a correct one, as indicated by @siaron ? It should work correctly then. If the issue still persists after changing it, please provide a minimal, complete, verifiable example that reproduces the issue.

admintertar commented 1 year ago

contextId

Yes, there is no problem after modifying the contextId