https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
spring
  • r

    Rodrigo Silva

    01/20/2020, 5:25 PM
    Is it a good pratice to create a kafka topic with Spring, or is creating using the CLI better?
    :google: 2
    t
    • 2
    • 1
  • c

    Czar

    01/22/2020, 7:20 AM
    I've just noticed this example in Spring docs:
    class PersonForm(
        @get:NotNull @get:Size(max=64)
        private val name: String,
        @get:Min(0)
        private val age: Int
    )
    Does this mean that we can finally use non-nullable properties in validated pojos and still get a nice validation error instead of kotlin's null passed into non-nullable property?
    q
    b
    l
    • 4
    • 11
  • d

    Dave Jensen

    01/22/2020, 7:04 PM
    How do I specify a Kotlin function as the
    mainClassName
    in the
    springBoot
    section of the build.gradle.kts? (The rest of the details in the thread)
    v
    • 2
    • 9
  • s

    Slackbot

    01/22/2020, 8:49 PM
    This message was deleted.
    t
    v
    • 3
    • 4
  • l

    Luca Clemente Gonzalez

    01/27/2020, 3:08 PM
    https://stackoverflow.com/questions/59878832/spring-scheduler-not-being-executed-if-its-component-class-is-not-injected
    n
    l
    b
    • 4
    • 15
  • c

    corneil

    01/28/2020, 11:05 AM
    How will the Spring DI Container create TriggerScheduler? You have a parameter 
    val scheduledTriggerExecutors: List<ScheduledTriggerExecutor>
     and I don't know how the DI is going to resolve that? You will need to remove @Component from TriggerScheduler and have an @Bean method in a @Configuration class to create this. Then it should behave as expected
    l
    • 2
    • 1
  • t

    tseisel

    02/05/2020, 9:55 AM
    Hi everyone. What could be a way to test a service that uses
    WebClient
    to perform requests ? Mocking
    WebClient
    does not seem to be a viable solution. I've seen something like
    WebClientTest
    on the web, but I'm unable to find the correct dependency or documentation about it.
    c
    k
    +3
    • 6
    • 9
  • d

    Dave Jensen

    02/06/2020, 4:02 AM
    Is it possible to use Moshi to handle json in Spring Boot instead of Jackson or Gson?
    b
    • 2
    • 1
  • d

    Dariusz Kuc

    02/11/2020, 12:23 AM
    hello! I'm looking into implementing some integration tests that require starting up the SpringBoot app, running some tests (through a plugin) and shutting down the app through Gradle. Maven has a built-in support for that (i.e.
    start
    and
    stop
    goals https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html). Based on https://github.com/spring-projects/spring-boot/issues/3982 and https://github.com/gradle/gradle/issues/1367 looks like there is no out of the box solution for that. Guess this could be done through the custom tasks that rely on Spring Actutator (as suggested here -> https://stackoverflow.com/questions/31407323/running-integration-tests-for-a-spring-boot-rest-service-using-gradle). Any suggestions?
    f
    t
    k
    • 4
    • 10
  • d

    dr.dreigh

    02/11/2020, 6:31 PM
    bit random, does anyone know what % of spring initializr projects are built with kotlin as a language ? (we're doing a talk for a Kotlin User Group)
    m
    • 2
    • 4
  • r

    Robert

    02/12/2020, 12:33 PM
    what's the common way to test
    suspend
    functions in Tests?
    runBlockingTest {..}
    from kotlinx-coroutines-test or is there some spring equivalent?
    j
    • 2
    • 1
  • r

    Robert

    02/12/2020, 2:29 PM
    Spring 2.2.x folks .. was it just a bootiful dream that one could use Constructor Injection in Junit5 Tests with SpringExtension? 🤔 🍃
    👍 1
    d
    • 2
    • 9
  • r

    Robert

    02/14/2020, 5:15 PM
    How would you do the following with Kotlin, Spring WebFlux + Kotlin Coroutines in a reactive Way: - Extract body (json) from ServerRequest. - Load a (template) ClassPathResource (json) , do String replacements with values extracted from the request? - Would a
    Mono
    be sufficient with a single map operation on the whole string? - Under the assumption it’s not a
    ClassPathResource
    but some expensive DiskIO: Would it make sense to Tokenize the File to a
    Flux/Flow<String>
    k
    • 2
    • 1
  • s

    scottiedog45

    02/17/2020, 5:44 PM
    What’s the usual Spring/Kotlin/Webflux object to use to intercept incoming reqests to check headers?
    d
    • 2
    • 1
  • s

    Sourabh Rawat

    02/19/2020, 8:41 AM
    what is the difference between
    bootJar
    and
    shadowJar
    . Can I use
    shadowJar
    for Spring boot applications?
    d
    m
    • 3
    • 8
  • g

    gbaldeck

    02/21/2020, 9:45 PM
    hi, I am using Spring Data JPA and creating some entities. I have the kotlin jpa plugin installed in Gradle so it should be making no-arg constructors for my entities. But I still get the error below in IntelliJ. Is there a project setting I need to change so IntelliJ recognizes I'm using the kotlin jpa plugin?
    a
    • 2
    • 3
  • a

    Amardeep

    02/22/2020, 1:14 AM
    Hi, I am writing a Spring Boot Kotlin micro service. I intend to use spring reactive stack along with Kotlin Flows/Coroutines. I want to log all incoming http request and response body in my micro service. What would be an appropriate approach to do that? Is writing a Filter which intercepts the request/response and reads the stream and then log it is safe and recommended? What other options I can explore? Thanks in advance
    g
    • 2
    • 2
  • n

    nfrankel

    02/23/2020, 8:46 AM
    and now that you are using everything explicit, you need to... no magic anymore, that’s the trade-off no magic means no instantiation of beans behind your back you need to declare everything by yourself
    g
    • 2
    • 10
  • c

    Czar

    02/23/2020, 10:55 AM
    This will fail to start with:
    Description:
    A component required a bean of type 'java.util.List' that could not be found.
    Action:
    Consider defining a bean of type 'java.util.List' in your configuration.
    Why is that? Doesn't collection autowiring work with Spring Fu?
    SomeApp_kt.kt
    n
    • 2
    • 16
  • s

    Sourabh Rawat

    02/24/2020, 3:43 PM
    what is more preferred? Spring AOP logging or logging using lambdas?
    a
    • 2
    • 1
  • s

    Swkng

    02/24/2020, 9:39 PM
    Hi everyone. Coming from Java and trying to understand how to use
    @JsonDeserializer
    and
    @JsonSerializer
    . By now all that have discovered is that Kotlin uses
    jackson-module-kotlin
    without any success though. Thanks for reading and helping this fellow software engineer.
    c
    • 2
    • 2
  • h

    hooliooo

    02/27/2020, 1:18 PM
    Is there a way to set client id + secret for OAuth2 at runtime for WebClient?
    c
    • 2
    • 4
  • a

    aksh1618

    02/27/2020, 6:30 PM
    I'm trying out bean & router DSLs:
    @SpringBootApplication
    class DemoApplication
    
    fun main(args: Array<String>) {
        runApplication<DemoApplication>(*args) {
            beans {
                bean {
                    router {
                        GET("hi") { ok().body("hi") }
                    }
                }
            }
        }
    }
    But I get 404 on
    localhost:8080/hi
    , am I missing something?
    s
    • 2
    • 2
  • s

    soudmaijer

    02/28/2020, 3:35 PM
    @sdeleuze I have an issue when using Web.Fn my metrics per route are not properly showing up in my actuator endpoint. I have this route defined: https://github.com/soudmaijer/spring-webfn-metrics/blob/master/src/main/kotlin/nl/sourcelabs/prometheus/demo/DemoApplication.kt#L31 but in the output of my metrics the path disappears and just displays: root. https://github.com/soudmaijer/spring-webfn-metrics/blob/master/actuator_output.txt#L5 When I convert it back to a @RestController all works fine again. Any ideas?
    s
    j
    • 3
    • 3
  • x

    XQDD

    03/06/2020, 5:03 AM
    How to solve this? It can actually run without any problem
    • 1
    • 5
  • r

    Robert

    03/06/2020, 12:48 PM
    Not sure if #spring or #coroutines: It only fails on certain environments
    - Kotlin + Depencendices: "1.3.61" - coroutines 1.3.+
    - Spring Boot 2.2.4.RELEASE
    2020-03-06 12:29:59.485 ERROR 28 --- [boundedElastic-5] reactor.core.scheduler.Schedulers        : Scheduler worker in group main failed with an uncaught exception
    java.lang.NoClassDefFoundError: kotlin/coroutines/AbstractCoroutineContextKey
    	at java.lang.ClassLoader.defineClass1(Native Method)
    e
    l
    s
    • 4
    • 31
  • l

    lucasqueiroz

    03/11/2020, 8:14 PM
    Hey guys, is there any alternative to Spring-retry? It doesn't seem to be maintained anymore, and some of the things I need aren't possible to do with it (example a bean with the default retrytemplate)
    n
    o
    r
    • 4
    • 7
  • k

    KyooSik Lee

    03/18/2020, 2:45 AM
    Hello, I am using reactive spring. Does anyone know how to put file inside
    ServerResponse
    ? I’m creating excel file by
    poi
    and I can’t find way to put this file inside ServerResponse
    m
    c
    • 3
    • 11
  • c

    Czar

    03/20/2020, 1:59 PM
    is updating to kotlin 1.3.70 planned for boot 2.3 or is 1.3.61 final?
    👍🏾 1
    s
    • 2
    • 1
  • j

    JP

    03/29/2020, 3:34 AM
    I got started with Spring Boot with Kotlin by following this tutorial https://spring.io/guides/tutorials/spring-boot-kotlin/. I am getting this message in IntelliJ as the attached image. Through searching, I read that this would not happen if
    jpa
    plugin is installed, but when I checked
    build.gradle.kts
    the
    jpa
    plugin was of course already installed, since I was following the steps in the tutorial.
    plugins {
        id("org.springframework.boot") version "2.2.6.RELEASE"
        id("io.spring.dependency-management") version "1.0.9.RELEASE"
        kotlin("jvm") version "1.3.71"
        kotlin("plugin.spring") version "1.3.71"
        kotlin("plugin.jpa") version "1.3.71"
        kotlin("plugin.allopen") version "1.3.71"
    }
    So what am I missing here?
    l
    • 2
    • 9
Powered by Linen
Title
j

JP

03/29/2020, 3:34 AM
I got started with Spring Boot with Kotlin by following this tutorial https://spring.io/guides/tutorials/spring-boot-kotlin/. I am getting this message in IntelliJ as the attached image. Through searching, I read that this would not happen if
jpa
plugin is installed, but when I checked
build.gradle.kts
the
jpa
plugin was of course already installed, since I was following the steps in the tutorial.
plugins {
    id("org.springframework.boot") version "2.2.6.RELEASE"
    id("io.spring.dependency-management") version "1.0.9.RELEASE"
    kotlin("jvm") version "1.3.71"
    kotlin("plugin.spring") version "1.3.71"
    kotlin("plugin.jpa") version "1.3.71"
    kotlin("plugin.allopen") version "1.3.71"
}
So what am I missing here?
I edited the kotlin plugins’ version from “1.3.71” to “1.3.70", and the message disappeared.
Could it be that it’s related to this issue: https://youtrack.jetbrains.com/issue/KT-36964, and the false positive is again caused?
No, actually after some while IntelliJ again showed the message
But I am able to build and run, either with version “1.3.71” or “1.3.70". So this does seem like a false positive
l

leodeng

03/29/2020, 2:58 PM
hibernate entity needs a no-arg constructor. use the kotlin noarg plugin (https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.noarg) or make it like
@Entity
class Article {
  var id: Long = 0
  var name: String = ""
  var desc: String? = null
}
j

JP

03/30/2020, 6:09 AM
@leodeng I think that’s automatically done via the jpa plugin, and that seems true since when I checked the project structure, it showed this:
l

leodeng

03/30/2020, 3:29 PM
hmm, i think you’re right about jpa plugin also applies the noarg plugin. i guess if you run gradle in command line, everything works fine? could it be the intellij version?
j

JP

03/31/2020, 12:04 PM
@leodeng Yes, IntelliJ complains, but I was still able to build and run the app.
l

leodeng

04/01/2020, 2:19 AM
i can only think of a few things to try but am not sure if those will help, like: update intellij to the latest version, enable annotation processing, change gradle runner to Gradle instead of IntelliJ IDEA
View count: 4