5

Just generated on https://start.spring.io/ Spring Boot 2.4.4 project with added Spring Boot Native 0.9.1-SNAPSHOT

and it fails to start within IDEA (so not yet even as native image)

The ApplicationContext could not start as 'org.springframework.aot.StaticSpringFactories' that is generated by the Spring AOT plugin could not be found.

Full output

/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=52158:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath ....
2021-03-20 22:07:21.264 ERROR 10192 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The ApplicationContext could not start as 'org.springframework.aot.StaticSpringFactories' that is generated by the Spring AOT plugin could not be found.

Action:

Review your local configuration and make sure that the Spring AOT plugin is configured properly.
If you're trying to run your application with 'mvn spring-boot:run', please use 'mvn package spring-boot:run' instead.
See https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#spring-aot for more details.


Process finished with exit code 1

I noticed that for my usual project with Web and JPA over hibernate some extra maven plugin were added by Initializr:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                    <image>
                        <builder>paketobuildpacks/builder:tiny</builder>
                        <env>
                            <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                        </env>
                    </image>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.experimental</groupId>
                <artifactId>spring-aot-maven-plugin</artifactId>
                <version>${spring-native.version}</version>
                <executions>
                    <execution>
                        <id>test-generate</id>
                        <goals>
                            <goal>test-generate</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.hibernate.orm.tooling</groupId>
                <artifactId>hibernate-enhance-maven-plugin</artifactId>
                <version>${hibernate.version}</version>
                <executions>
                    <execution>
                        <id>enhance</id>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                        <configuration>
                            <failOnError>true</failOnError>
                            <enableLazyInitialization>true</enableLazyInitialization>
                            <enableDirtyTracking>true</enableDirtyTracking>
                            <enableAssociationManagement>true</enableAssociationManagement>
                            <enableExtendedEnhancement>false</enableExtendedEnhancement>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • Checking https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#spring-aot `Sources are generated in target/generated-sources/spring-aot/` So I did run maven from command line `mvn package` and could move to next error – Paul Verest Mar 20 '21 at 14:58

2 Answers2

4

Do read https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#spring-aot carefully, it has exact steps for IDEA (and tips for Eclipse and VSCode)

In the Maven tool window, go to "Plugins" and map:

  • Right click on spring-aot:generate then click on "After build".

  • Add the JUnit configuration (or just try to run a firs time your tests) and then right click on `spring-aot:test-generate then click on "Execute Run/Debug …​" then select your JUnit test configurations.

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
1

Here is a snapshot to config it in my IDE.

enter image description here