spring-native
spring-native copied to clipboard
Add support for spring-cloud-gateway
Describe the issue
- route setting application.yml
- (not native build) run test, make jar, run jar works.
- native build success.
- run error command
$ ./target/demo
Steps to reproduce the issue
- start.spring.io
- add spring native, spring cloud gateway
- generated
- sample application yml
spring:
cloud:
gateway:
routes:
- id: example
uri: http://127.0.0.1:8000
predicates:
- Path=/
- mvnw -Pnative clean package -DskipTests
Describe GraalVM and your environment:
- GraalVM version : graalvm-ce-java17-22.0.0.2
- JDK major version: openjdk version "17.0.2"
- OS: e.g. macOS Monterey
- Architecture: AMD64
More details
2022-05-04 20:43:47.216 ERROR 29336 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.cloud.gateway.routes[0].predicates[0]' to org.springframework.cloud.gateway.handler.predicate.PredicateDefinition:
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.cloud.gateway.handler.predicate.PredicateDefinition]
Action:
Update your application's configuration
You can fix that issue by adding a typehint:
@NativeHint(types = {
@TypeHint(types = PredicateDefinition.class, access = TypeAccess.PUBLIC_CONSTRUCTORS)
})
but the main problem here is that Spring native doesn't support Spring Cloud Gateway yet.
May I ask, I do as above, add annotations, or there is a new error, how should I solve it:

Please,Is Groovy now supported
There is no support for spring cloud gateway yet. You can now either try to add a lot of type hints or you run your application with the native agent which generates config for you. The image will work but may not have the optimal footprint.
To solve the problem in your screenshot, you have to add type hints for PathRoutePredicateFactory$Config, which is an inner class. You just have added type hints for the outer class.
Spring Native is now superseded by Spring Boot 3 official native support, see the related reference documentation for more details.
As a consequence, I am closing this issue, and recommend trying your use case with latest Spring Boot 3 version. If you still experience the issue reported here, please open an issue directly on the related Spring project (Spring Framework, Data, Security, Boot, Cloud, etc.) with a reproducer.
Thanks for your contribution on the experimental Spring Native project, we hope you will enjoy the official native support introduced by Spring Boot 3.