spring-native icon indicating copy to clipboard operation
spring-native copied to clipboard

Add support for spring-cloud-gateway

Open bluenux opened this issue 3 years ago • 4 comments

Describe the issue

  1. route setting application.yml
  2. (not native build) run test, make jar, run jar works.
  3. native build success.
  4. run error command $ ./target/demo

Steps to reproduce the issue

  1. start.spring.io
  2. add spring native, spring cloud gateway
  3. generated
  4. sample application yml
spring:
  cloud:
    gateway:
      routes:
        - id: example
          uri: http://127.0.0.1:8000
          predicates:
            - Path=/
  1. 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

bluenux avatar May 04 '22 13:05 bluenux

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.

mhalbritter avatar Jun 09 '22 11:06 mhalbritter

May I ask, I do as above, add annotations, or there is a new error, how should I solve it: 711654919642_ pic 721654919665_ pic

huiji121 avatar Jun 12 '22 03:06 huiji121

Please,Is Groovy now supported

huiji121 avatar Jun 12 '22 04:06 huiji121

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.

mhalbritter avatar Jun 13 '22 07:06 mhalbritter

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.

sdeleuze avatar Jan 02 '23 11:01 sdeleuze