spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.94k stars 1.28k forks source link

Process AOT - Error with "composite" profile in Spring Cloud Config Server generating Native Image #2395

Closed dani-house closed 1 month ago

dani-house commented 3 months ago

Hi,

It's not possible to generate a native image with the composite profile. Executing the process-aot step, we get the error:

Default code generation is not supported for bean definitions declaring an instance supplier callback: Root bean: class [org.springframework.cloud.config.server.support.**EnvironmentRepositoryProperties**]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null

application.yaml sample:

spring:
  application:
    name: config-server

  profiles:
    active: composite

  cloud:
    refresh:
      enabled: false

    config:
      server:
        composite:
          - type: git
            uri: https://dev.azure.com/xxxx/_git/repo1
            search-paths: '{application}'
            force-pull: true
            refresh-rate: 5
            try-master-branch: false
            default-label: main
            clone-on-start: true
          - type: git
            uri: https://dev.azure.com/xxxx/_git/repo2
            search-paths: '{application}'
            force-pull: true
            refresh-rate: 5
            try-master-branch: false
            default-label: main
            clone-on-start: true
ryanjbaxter commented 3 months ago

Did you follow the instructions here? https://docs.spring.io/spring-cloud-config/reference/server/aot-and-native-image-support.html

cc: @OlgaMaciaszek

dani-house commented 3 months ago

Config server compiles and it runs correctly with a simple git configuration, like this:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://dev.azure.com/xxx/_git/repo1
          password: "xxxxx"
          username: "xxxxx"

Compilation error occurs when configuring "composite" profile.

OlgaMaciaszek commented 2 months ago

This is, unfortunately, a known issue in Framework: https://github.com/spring-cloud/spring-cloud-function/issues/1074; we'll probably need to rewrite it to avoid using the supplier or manually create the AotContribution. Will look further into it.