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

Spring AOT does not generate spring.components #1682

Closed sendev1 closed 2 years ago

sendev1 commented 2 years ago

Hi,

In my application, Spring AOT is not generating spring.components file. Because of this when we compile and run native image bean creating exception happens. Here is the build directory for the app and as you can see there is no spring.components file but there are many @Components and @Services present in the app

image

Here is the build.gradle

// ========== 2. Apply plugins plugins {

id 'org.springframework.boot' version "2.7.0"

id 'org.springframework.experimental.aot' version "0.12.0"

} when we run native build we pass tracing = false tracing=false ./gradlew nativeRun springAot { println "Printing tracing agent boolean value= " + System.getenv('tracing') if(System.getenv('tracing') == 'true'){ println "Setting AotMode.NATIVE_AGENT " mode = AotMode.NATIVE_AGENT } else { println "Setting AotMode.NATIVE" // default mode is NATIVE mode = AotMode.NATIVE } //Added because LocalAthenaBrowserService has 2 main classes and generateAot needs to know which main class to use mainClass='com.vue.labs.LocalAbeServiceApplication' // Removing unnecessary supports from GraalVm native images to optimize the size of the native image // Need spring SpEL support because SpEL is used in localabeservice. e.g: @Value("${app.version:dev}") removeSpelSupport = false // Removing YAML support removeYamlSupport = true // Need XML support for handling results in native image removeXmlSupport = false // Remove JMX Support removeJmxSupport = true }

But for one of the sample we tried the file is present for the same build.gradle configuration

image