https://kotlinlang.org logo
Join Slack
Powered by
# spring
  • s

    sdeleuze

    12/05/2024, 2:03 PM
    Spring Framework
    main
    branch is now using Kotlin 2.1 as a baseline! • Bluesky • Mastodon • Linkedin
    K 21
    K 8
    ❤️ 7
    🚀 8
    kodee walking 1
  • c

    corneil

    01/13/2025, 3:46 PM
    What do we have to add when using
    org.springframework.boot:spring-boot-configuration-processor
    to ensure propeties classes with
    @ConfigurationProperties
    are properly detected.
    m
    • 2
    • 3
  • m

    mathias8dev

    01/16/2025, 11:04 AM
    Hello 👋 I am using Spring ApplicationEvent in async mode (with the @Async annotation) in a spring-webflux project. There is no documentation about that. Will this have any issue on the workload or something else please in production ?
    not kotlin but kotlin colored 1
  • u

    ursus

    01/18/2025, 11:45 PM
    Anyone know how to get
    List
    working with
    restTemplate.getForObject<List<X>>
    kotlin extension? I'm getting class cast exceptions
    d
    k
    • 3
    • 8
  • k

    kurt_steiner

    01/21/2025, 2:00 PM
    Currently, I only have experience developing web applications using the Spring Framework. However, I recall that the dependency injection feature in Spring is used for decoupling code. I'm curious about how this functionality is embodied in other types of projects. Could you provide some repositories for reference?
    not kotlin but kotlin colored 1
    m
    • 2
    • 2
  • u

    ursus

    01/28/2025, 3:19 AM
    Copy code
    listOf(
        Person(
            name = "foo",
            age = 44,
            fooBar = "lol",
            isImportant = true,
            isNew = true
        )
    )
    Why does this get serialized into json as
    [{"id":null,"name":"foo","age":44,"fooBar":"lol","new":true,"important":true}]
    ? I.e. missing the
    is
    prefixes? What's even worse is when I try to deserialize the same json that was just serialized, I'll get errors. Broken by default
    t
    k
    • 3
    • 3
  • e

    Eugen Martynov

    01/30/2025, 9:31 AM
    Hey hey Kotlin Spring people - could you drop reasons in thread why you would still develop in kotlin especially java so advanced in feature parities these days?
    👀 1
    r
    t
    +8
    • 11
    • 14
  • t

    Teodor Irkhin

    01/31/2025, 10:01 AM
    kodee loading Following yesterday’s discussion on the advantages of Kotlin over Java with Spring. What do you feel is missing in Kotlin + Spring tooling support in IDEA these days, what could be better?
    r
    w
    +2
    • 5
    • 4
  • s

    sdeleuze

    02/14/2025, 5:39 PM
    A proposal for bridging Spring
    @Configuration
    with functional bean registration. Feedback is welcome. https://github.com/spring-projects/spring-framework/issues/18353#issuecomment-2659889622
  • s

    sdeleuze

    02/14/2025, 5:50 PM
    If you liked Spring Fu, read this proposal 😉
  • r

    Robert Jaros

    02/14/2025, 6:08 PM
    Wasn't spring-fu about full control over the configuration and bean registration process (including when the whole initialization code is executed)? With this new proposal is doesn't seem to be the case (the developer have no way to decide when the
    initialize
    method is executed). Am I correct?
  • s

    sdeleuze

    02/14/2025, 8:10 PM
    That's true, and I have refined my comment accordingly. This proposal only focus on the part that is not incompatible with Spring Boot core principles like auto-configuration. Spring Fu was IMO too far away from Spring Boot, we have to find a better tradeoff between explicit configuration and auto-configuration. But this improvement could allow later a more explicit configuration model for Spring Boot if the Boot team and community want to support that.
    👍 1
  • s

    sdeleuze

    02/16/2025, 1:54 PM
    My KotlinConf talk « Next level Kotlin support in Spring Boot 4 » has been accepted. If you want to help to spread the word: • Linkedin • Bluesky • Mastodon See you at Copenhagen in May!
    👍 9
    🎉 8
    👍🏽 1
    👍🏻 1
    👍🏾 1
  • e

    Elise

    03/02/2025, 1:01 PM
    How does Spring MVC work with kotlin coroutine? Do I always have to use kotlin coroutine for my server code? Any examples would be appreciated.
    j
    • 2
    • 1
  • r

    Robert Jaros

    03/02/2025, 8:47 PM
    Anyone here knows what is wrong with
    spring-dependency-management
    plugin and Kotlin/JS compiler? Not long ago I've reported it breaks incremental compilation of K/JS (https://youtrack.jetbrains.com/issue/KT-74378). Now I have problems with serialization (see: https://kotlinlang.slack.com/archives/C7A1U5PTM/p1740943473638099). I've always thought this plugin just reads some BOMs and auto-applies correct version of various dependencies. But how it is possible that it breaks compilation?
  • s

    sdeleuze

    03/06/2025, 6:56 PM
    I have just merged into Spring Framework main branch a first-class support for programmatic bean registration for Java and Kotlin. Will be part of the upcoming Spring Framework 7.0.0-M3. https://docs.spring.io/spring-framework/reference/7.0-SNAPSHOT/core/beans/java/programmatic-bean-registration.html • Bluesky • Mastodon • LinkedIn
    🎉 12
    K 9
    👏 4
    👏🏽 1
    • 1
    • 1
  • e

    Eric

    03/27/2025, 12:52 PM
    I'm trying to extend the RabbitMQ
    AbstractRoutingConnectionFactory
    and override
    getTargetConnectionFactory
    . My function signature is just
    override fun getTargetConnectionFactory(lookupKey: Any?): ConnectionFactory?
    but the compiler is rejecting that, and only accepts
    override fun getTargetConnectionFactory(lookupKey: Any): ConnectionFactory
    . Looking at how
    getTargetConnectionFactory
    is used, it can clearly accept a null
    lookupKey
    and return a null
    ConnectionFactory
    . Am I missing something obvious here? I don't see any nullability annotations on
    getTargetConnectionFactory
    AbstractRoutingConnectionFactory
    or any
    package-info.java
    that specifies package-wide null behavior. Spring Boot 3.4.3, spring-rabbit 3.2.3, Kotlin 1.9.23.
  • h

    horse_badorties

    03/31/2025, 2:11 PM
    According to the dependency documentation, the upcoming Spring Boot 3.5 will still be on Kotlin 1.9.x. Is there any information about why they do not upgrade to 2.x?
    r
    h
    h
    • 4
    • 4
  • t

    thanksforallthefish

    04/02/2025, 8:08 AM
    Hello, I have something that I cannot wrap my head around when it comes to observability and coroutines (in a spring boot application). In particular, we want to restore propagate tracing information through SQS, so we are saving trace information on the producer side within the message, and on the consumer we restore the trace before processing the message. Pseudocode (no worries, more code in thread):
    Copy code
    // producer thread, saves its trace information within the message
    producer.produce(message.withTraceDetails())
    
    // consumer thread, actually even another application instance
    // up to this consumer.read, its an independent trace
    val message = consumer.read()
    processAfterRestoring(message.traceDetails()) {
      // here the trace is restored from the message
      process(message)
    }
    
    fun processAfterRestoring(sourceTrace: Trace, supplier: () -> Any)
    The code we have works in normal scenarios, but not when
    process(message)
    uses coroutines, eg
    Copy code
    // here we have TraceONE
    val message = consumer.read()
    processAfterRestoring(message.traceDetails()) {
      // here the trace is restored from the message
      process(message)
    }
    
    fun process(message: Message) {
      // here the trace is restored from the message
      launchNewCoroutine {
        // but here the trace is again TraceONE
        doSomethingOn(message)
      }
    }
    
    fun processAfterRestoring(sourceTrace: Trace, supplier: () -> Any)
    I reproduce some more code (in thread, hopefully I captured all the relevant pieces). I guess the 3 questions that pop up to me are: • are we restoring traces incorrectly (not kotlin)? • is there some issue with our Spring context config (also not kotlin)? • what magic am I not seeing in
    observationRegistry.asContextElement()
    that causes the issue (since when we don't use coroutines, restoring works I am kinda discounting the first 2 questions and focusing more on this last one)?
    e
    • 2
    • 3
  • p

    Pritt Balagopal

    04/02/2025, 7:36 PM
    Does Kotlin support the annotations present in
    org.springframework.lang
    ? The online Javadoc for the website does indicate that it does https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/package-summary.html however, on Kotlin's own source file, it is not mentioned anywhere here: https://github.com/JetBrains/kotlin/blob/master/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt. I am confused, does Kotlin support it or not? And if so, how does it do so despite not being listed?
    j
    k
    s
    • 4
    • 10
  • w

    wakingrufus

    04/11/2025, 8:52 PM
    My talk on spring boot + functional kotlin at devnexus is up on youtube: I hope i did it justice!

    https://www.youtube.com/watch?v=9njQ8Lun36c▾

    ❤️ 3
    👏 1
    e
    • 2
    • 2
  • e

    Edgar

    04/12/2025, 10:37 AM
    guys anyone encountered same problem in kotlin spring boot https://stackoverflow.com/questions/79570300/om-mongodb-mongocommandexception-command-failed-with-error-8000-atlaserror
    j
    k
    • 3
    • 2
  • p

    Pihentagy

    04/14/2025, 10:46 AM
    Say I have a
    createdAt
    field in my
    @Entity
    . and it gets its value as the Entity is created. Can this info be utilized, so that "all saved entity has non-null createdAt" at kotlin level, or do I have to check against null every time? Or I have no choice but declare it as
    Copy code
    var timestamp: Instant? = null,
    d
    s
    • 3
    • 5
  • e

    Emil Kantis

    04/29/2025, 11:01 AM
    Are there any out-of-the-box solutions for propagating traces across Kotlin's coroutine
    Channel
    ?
  • a

    Alex

    05/09/2025, 5:32 PM
    Hi folks, can somebody please help me figure out why my app is being booted in 20+ seconds instead of 5-6 like it was just this morning? I didn't do any particular changes to gradle, I didn't update any version dependencies, it just suddenly started to be incredibly slow. I switched to Linux from Windows for the performance and because Gradle kept hanging up in dying on Windows and the only way to continue work was to reboot, everything was blazingly fast but now for no specific reason everything's just slow af
    e
    a
    • 3
    • 7
  • f

    Francisco Ripoli

    05/22/2025, 1:50 PM
    I know this might not be the correct place to ask, but does anyone know why spring decided to stop publishing their
    spring-boot-parent pom
    ?
    Copy code
    spring-boot-parent
    The spring-boot-parent module is no longer published. It provides dependency management for internal dependencies used, for example, in Spring Boot's own tests. If you were using spring-boot-parent, replace it with dependency management of your own that meets your application's needs.
    s
    h
    j
    • 4
    • 4
  • s

    sdeleuze

    05/26/2025, 6:20 AM
    The source code of Spring Petklinik, the new reference Kotlin fullstack application I have built for my KotlinConf and Spring IO talks, is now available at https://github.com/sdeleuze/spring-petklinik. I will continue to refine it. If you want to spread the word: - LinkedIn - BlueSky - Mastodon
    ❤️ 12
    K 10
    r
    t
    • 3
    • 10
  • p

    Paul N

    05/30/2025, 12:40 PM
    So I'm upgrading from Spring 3.2 to 3.4 In Spring 3.2 this way of registering an initializer to kick off registering beans for the kotlin beans DSL is deprecated:
    Copy code
    context.initializer.classes: mypackage.BeansInitializer
    So instead I've used META-INF/spring.factories:
    Copy code
    org.springframework.context.ApplicationContextInitializer=\
     mypackage.BeansInitializer
    and my application breaks. The issue is that in my BeansInitializer class I'm using ref() to inject a bean that is created via an @Component annotation in a jar file. The trouble is that now the initalizer seems to run before it's dependent bean is created, so I get a message like this: A component required a bean of type 'Whatever' that could not be found. How do correctly use the kotlin beans DSL in Spring 3.4.5 ? NB I can't modify the main function to add the initializer that way as that only works for the main application, not tests, and I don't want to add the initializer to loads of integration tests either.
    h
    • 2
    • 5
  • k

    Kev

    06/21/2025, 8:45 AM
    Hello. I have a very basic setup for running Springboot tests using a postgresql test container. The first test runs fine, however subsequent tests all fail and yell the following at me:
    Copy code
    2025-06-21T10:42:16.910+02:00  WARN 74817 --- [app] [    Test worker] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to validate connection org.postgresql.jdbc.PgConnection@5a0c0680 (This connection has been closed.). Possibly consider using a shorter maxLifetime value.
    My base test class looks like this:
    Copy code
    @Testcontainers
    abstract class SpringBootTestBase {
    
        companion object {
    
            @Container
            @JvmStatic
            val postgres = PostgreSQLContainer<Nothing>("postgres:15").apply {
                withDatabaseName("testdb")
                withUsername("test")
                withPassword("test")
            }
    
            @JvmStatic
            @DynamicPropertySource
            fun registerPgProperties(registry: DynamicPropertyRegistry) {
                registry.add("spring.datasource.url", postgres::getJdbcUrl)
                registry.add("spring.datasource.username", postgres::getUsername)
                registry.add("spring.datasource.password", postgres::getPassword)
            }
        }
    }
    I have overridden properties for hikari. I have no special test properties either. Any idea?
    m
    • 2
    • 4
  • d

    Distractic

    07/09/2025, 8:56 PM
    Hello everyone I'm creating an app in Kotlin with Spring. I configure everything to use Kotlin Serialization instead of Jackson and that works. However, I would like to generate the OpenApi doc. But I can't find a plugin (gradle) or dependencies that support the Kotlin Serialization annotation for my Spring controller's DTO. So two questions for you: • Is there a plugin or dependency that support Kx-serializable • (If not for the first question) Do you recommend me to go back on Jackson due to the lack of support of Kotlin Serializable with Spring Have a good day