Spring Boot 3 Native demo project.
Build OS dependant native image
./gradlew nativeCompile
Directly build docker image (Linux OS) with integrated Paketo Buildpacks.
./gradlew bootBuildImage
Note
|
You can find reachability metadata for dependencies in ~.gradle/native-build-tools/repositories. |
Project is build to cause a failing tests ONLY for the native build due to use of Reflection.
HelloControllerTest
passes fine in JVM.
./gradlew test
But test method shouldReturnMessageFromReflectiveInstance
will fail on native, displaying error bellow.
./gradlew nativeTest
Failures (1): JUnit Jupiter:HelloControllerTest:shouldReturnMessageFromReflectiveInstance() MethodSource [className = 'com.example.boot3ready.HelloControllerTest', methodName = 'shouldReturnMessageFromReflectiveInstance', methodParameterTypes = ''] => jakarta.servlet.ServletException: Request processing failed: java.lang.NoSuchMethodException: com.example.boot3ready.HelloService.hello(java.lang.String) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:895) jakarta.servlet.http.HttpServlet.service(HttpServlet.java:668) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:880) org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:72) [...] Caused by: java.lang.NoSuchMethodException: com.example.boot3ready.HelloService.hello(java.lang.String) java.lang.Class.getMethod(DynamicHub.java:2227) com.example.boot3ready.HelloController.reflectionInvocation(HelloController.java:43) com.example.boot3ready.HelloController.hello(HelloController.java:34) java.lang.reflect.Method.invoke(Method.java:568) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) [...]