Skip to content

Document the need for compilation with -parameters when targeting a native image #33182

@michalkrajcovic

Description

@michalkrajcovic

Describe the bug

Spring Boot 3 Native - "Could not bind properties" error when properties class located in another module uses @ConstructorBinding in multi-module gradle project

To Reproduce
Environment

  • Spring Boot: 3.0.0-RC2
  • Native Buildtools: 0.9.17
  • GraalVM version : graalvm-ce-java17-22.3.0
  • JDK version: openjdk 17.0.5
  • Architecture: AMD64

Sample project
https://github.com/michalkrajcovic/spring-native-multi-modules-bind-properties

Compile

./gradlew nativeCompile

Run

./greetings-app/build/native/nativeCompile/greetings-app

Fails with

o.s.c.support.GenericApplicationContext  : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'application': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'greetings-com.example.greetings.configuration.GreetingsProperties': Could not bind properties to 'GreetingsProperties' : prefix=greetings, ignoreInvalidFields=false, ignoreUnknownFields=true
Description:
Failed to bind properties under 'greetings' to com.example.greetings.configuration.GreetingsProperties:
    Reason: java.lang.IllegalStateException: Failed to extract parameter names for public com.example.greetings.configuration.GreetingsProperties(java.lang.String)

Runs without issues on JVM

./gradlew bootRun

Expected behavior
Application starts without issues using JVM and native image.

Observation
Does not fail when properties class uses setters see brach setter. Also ConstructorBinding doesn't fail in single module project see branch single-module

Originally reported for Spring Boot 2.7.5 in spring-native

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions