https://kotlinlang.org logo
Join SlackCommunities
Powered by
# spring
  • a

    André Martins

    10/16/2024, 9:25 AM
    Hey guys, I have a simple data class for configuration like the following
    Copy code
    @Configuration
    @ConfigurationProperties(prefix = "my-config")
    data class MyConfig(
        var blacklist: List<BlackListEntry> = emptyList(),
    )
    
    data class BlackListEntry(
        val name: String,
        val values: List<String> = emptyList(),
    )
    And I'm using
    spring.config.import
    to import an additional application.yaml in my environment. The thing is I get
    java.lang.IllegalStateException: No setter found for property: blacklist
    When I change the blacklist to be a MutableList it works, does spring first instantiate MyConfig for the base application.yaml and then try to call the setters with the additional imports? Shouldn't it merge the yamls first and only call the constructor once? Any ideias how can I keep the list as immutable? Im using spring-boot 3.2 btw Thanks in advance ✌️
    d
    p
    j
    • 4
    • 17
  • p

    Pihentagy

    10/22/2024, 6:36 AM
    (( I cannot write to the https://gitter.im/spring-projects/spring-boot channel. Logging in with github/twitter does not work. Also I cannot write if I join via element.io app. ))
  • p

    Pihentagy

    10/22/2024, 6:38 AM
    Ah, found #C0BLHCSHZ, see there https://kotlinlang.slack.com/archives/C0BLHCSHZ/p1729579151704499
    🙌 1
    k
    • 2
    • 11
  • s

    Simon Nyström

    11/11/2024, 2:08 PM
    I have a really strange issue that I can't quite figure out. I've upgraded to Spring Boot 3 in one of my projects and after this it seems
    @GetMapping
    is working as usual but something has changed with
    @PostMapping
    ? It correctly maps the
    @GetMapping
    methods but debug logs this for my
    @PostMappings
    :
    Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
    Any ideas what I can do to fix this?
    ✅ 1
    • 1
    • 2
  • r

    Robert Jaros

    11/13/2024, 6:04 PM
    I have just enabled K2 mode in IntelliJ. My spring boot project uses
    kotlin-spring
    plugin but now I'm seeing
    Classes annotated with '@Configuration' could be implicitly subclassed and must not be final
    errors for all my configuration classes. Is this a known issue?
    j
    r
    j
    • 4
    • 18
  • 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
    • 3
    • 2
  • 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