1

I've got a problem with Spring-native and it's not loading my RestControllers (and most likely Services) from dependencies. My project setup looks like this: I got a bunch of independent Spring Boot Applications and grouped them together in an all in one runner like this.

@SpringBootApplication
@NativeHint(options = { "--enable-all-security-services" }, resources = {
    @ResourceHint(patterns = "eu/neclab/ngsildbroker/*/controller/*.java"),
    @ResourceHint(patterns = "org/flywaydb/core/internal/version.txt") }, types = {
            @TypeHint(types = { EntityController.class }) })
public class Runner {

public static void main(String[] args) throws Exception {
    SpringApplication.run(new Class[] { RegistryHandler.class, HistoryHandler.class, 
    QueryHandler.class,
            SubscriptionHandler.class, EntityHandler.class }, args);
}

}

https://github.com/ScorpioBroker/ScorpioBroker/blob/ldlibchange/AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java

From Java this all works and the Spring Apps fom my dependencies are being properly loaded and provide the defined RestControllers.

Now i started playing around with Spring-native and can get it all compiled now and it's also taking in dependencies (i get a class not found on build when the correct ones are not installed in maven) my pom for native looks like this (more or less copy paste from the tutorial)

<profile>
        <id>native</id>
        <activation>
            <property>
                <name>native</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.experimental</groupId>
                    <artifactId>spring-aot-maven-plugin</artifactId>
                    <version>0.11.0</version>
                    <executions>
                        <execution>
                            <id>generate</id>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <image>
                            <builder>paketobuildpacks/builder:tiny</builder>
                            <env>
                                <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                            </env>
                            <name>scorpiobroker/aaio</name>
                        </image>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

... however none of the restcontrollers is getting loaded i always get a 404. I tried all kinds variations of NativeHints but i can't get it to load the RestControllers. Does anyone have an Idea how i tell Spring-Native to load my RestControllers? I thought loading it through SpringApplication.run should load all of the modules but it seems Spring-Native can't handle it like that. Any hint or help would be appreciated.

0 Answers0