spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

@ConfigurationProperties only support for class in the current app,defined class in dependent jar will encounter param BindException #1692

Closed enderwsp closed 2 years ago

enderwsp commented 2 years ago

first ,clone from https://github.com/spring-projects-experimental/spring-native

second ,go to the path main/samples/boot-features

then ,exe build.sh

default demo is ok,

but,in my project ,i need define class with @ConfigurationProperties in dependent jar

so ,i move follow class to a new dependent project ,[com.example:boot-features-dep:0.0.1-SNAPSHOT] https://github.com/spring-projects-experimental/spring-native/blob/main/samples/boot-features/src/main/java/com/example/bootfeatures/Creds.java exe mvn clean install in project boot-features-dep

add dependency [com.example:boot-features-dep:0.0.1-SNAPSHOT] into follow pom https://github.com/spring-projects-experimental/spring-native/blob/main/samples/boot-features/pom.xml

then re run build.sh

i can get bin [./target/boot-features] but will get error when exe it: GenericApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'CLR': Unsatisfied dependency expressed through field 'credentials'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'credentials-com.example.bootfeaturesjar.Creds': Could not bind properties to 'Creds' : prefix=credentials, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'credentials' to com.example.bootfeaturesjar.Creds

sdeleuze commented 2 years ago

Hi, thanks for raising this issue, there is indeed maybe a limitation in Spring Native support on that. Since we have moved most of our effort into Spring Boot 3 native support, could you please try the same use case with Spring Boot 3 snapshot, and create an issue on Spring Boot issue tracker with a repro if that is not supported?

spring-projects-issues commented 2 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 2 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.