Skip to content

Only the last RouterFunction<> is available with the Kotlin bean DSL #14295

Closed

Description

@tgirard12

I have an app that add several RouterFunction<ServerResponse> with the Kotlin bean DSL and
only the routes from the latest bean of type RouterFunction<> is available on the server.

I have test this app with Spring-boot 2.0.4 and 2.1.0.M2 on Netty.

This is a sample app. You can change the order of the two router declaration and re-run the Unit test.

spring-boot_several-router.zip

Activity

  1. added
    status: waiting-for-triage
    on Sep 4, 2018
  2. self-assigned this
    on Sep 4, 2018
  3. bclozel commented on Sep 4, 2018

    @bclozel
    Member

    Hi @tgirard12 , thanks for the repro project.

    This looks like a usability/implementation/documentation issue in the bean registration DSL. I've created SPR-17242 for that. It seems defining multiple beans of the same types without providing a bean name is the source of the problem here.

    In the meantime, you can use the @Bean variant when registering beans, or add bean names like this:

    val beans = beans {
        // TODO Change the order of the declaration
        bean("fooRouter") { fooRouter() }
        bean("barRouter") { barRouter() }
    }

    I'm closing this issue as there's nothing we can do in Spring Boot.

  4. added
    status: invalid
    and removed
    status: waiting-for-triage
    on Sep 4, 2018
  5. tgirard12 commented on Sep 6, 2018

    @tgirard12
    Author

    Thanks for the quick reply and creating this issue, it fixed my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: invalid

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions