https://kotlinlang.org logo
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
  • a

    Ayodele

    09/01/2020, 10:27 AM
    Hi guys please i'm using the twilio API to send SMS I noticed that when i put the implementation under a Restcontroller in the Application.kt file just for test , it was able to send sms to my phone But when i moved the implementation to the controller package it gave me the error
    The 'From' number xxx is not a valid phone number, shortcode, or alphanumeric sender ID.
    d
    • 2
    • 1
  • n

    nathan

    09/06/2020, 6:53 PM
    //Controller
     @PatchMapping("/comment/{id}/")
        fun PatchCommentById(@PathVariable id: Long, @RequestBody comment: Comment): ResponseEntity<Comment> {
        
            val updatedComment = repo.save(Comment(
                    id = id,
                    body = comment.body,
                    video_link = comment.video_link,
                    image_link = comment.image_link,
            ))
            return ResponseEntity.ok(updatedComment)
        }
    how would u partial update this?
    a
    t
    c
    • 4
    • 6
  • n

    nathan

    09/12/2020, 2:28 AM
    how would you implement websockets into spring boot?
    :stackoverflow: 1
    t
    • 2
    • 1
  • g

    Greg Steckman

    09/12/2020, 3:31 AM
    Hi All. I am getting build errors when using the following plugins:
    id("io.spring.dependency-management") version "1.0.10.RELEASE"
    id("org.springframework.boot") version "2.3.3.RELEASE"
    Even without any Spring dependencies declared. If I don't include the dependency-management plugin, the errors do not occur. The errors are:
    w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
        C:/Users/Greg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.10/998caa30623f73223194a8b657abd2baec4880ea/kotlin-stdlib-jdk8-1.4.10.jar (version 1.4)
        C:/Users/Greg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar (version 1.3)
        C:/Users/Greg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar (version 1.3)
        C:/Users/Greg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.10/6229be3465805c99db1142ad75e6c6ddeac0b04c/kotlin-stdlib-common-1.4.10.jar (version 1.4)
    w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
    and:
    e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at (8,13) in C:/Users/Greg/Documents/git/test/src/jsMain/kotlin/client.kt
            at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.logOrThrowException(ExpressionTypingVisitorDispatcher.java:253)
    Long stack trace omitted, followed by
    Caused by: java.lang.NoSuchMethodError: 'kotlin.sequences.Sequence kotlin.sequences.SequencesKt.flatMapIterable(kotlin.sequences.Sequence, kotlin.jvm.functions.Function1)'
            at org.jetbrains.kotlin.resolve.calls.components.CollectionTypeVariableUsagesInfo.getDependentTypeParameters(ResolutionParts.kt:393)
            at org.jetbrains.kotlin.resolve.calls.components.CollectionTypeVariableUsagesInfo.getDependentTypeParameters$default(ResolutionParts.kt:389)
    This was with a new Multiplatform Kotlin project created in IntelliJ, but just adding those 2 plugins to the build.gradle.kts. I think this is an issue with the Spring dependency-management plugin. I am not sure if this is the best place to ask for help with this, if it is a bug or something I am doing wrong. If I should file a bug report in another Spring channel, please advise where that should be. Thanks!
    t
    • 2
    • 2
  • w

    Wesley Acheson

    09/16/2020, 10:29 AM
    I don't know if this is the correct place to talk about this. I've started to use spring-auto-restdoc (third party project). It infers a property in the api is optional based on if its a nullable type. However I've got a few data classes that use default values, which are not marked as nullable. So from an API consumers point of view they are nullable. Whats the best way to approach this? Mark the values (
    val
    as nullable ). This leads to unnecessary null checks later. Or somehow change how Jackosn creates its
    PropertyMetadata
    object. --- I'm going to cross post to stack overflow.
    t
    • 2
    • 5
  • m

    Michael de Kaste

    09/16/2020, 11:00 AM
    Hello, the code completion plugin broke an unknown time ago for us for https://blog.jetbrains.com/idea/2018/10/kotlin-jpa-and-spring-data/ no longer do we get suggestions for repository extended classes, anyone know why?
    • 1
    • 2
  • a

    alwyn

    09/17/2020, 7:20 PM
    Guess it would be easier to just make it open and make the setter private...
    j
    • 2
    • 11
  • a

    Ayodele

    09/18/2020, 8:20 AM
    Hi guys, please maven is not running my tests. I have gone through google, but none of the solutions seems to be working
    a
    • 2
    • 3
  • a

    AlexJuca

    09/20/2020, 9:53 PM
    Requirekt provides idiomatic preconditions for spring boot. :kotlin:🎉 The idiomaticity and power of kotlins 
    require
     for spring boot rest API's. 👌 v1.1.0 now supports custom error responses! https://github.com/nextbss/requirekt
    t
    • 2
    • 1
  • a

    Ayodele

    09/21/2020, 2:47 PM
    Hello guys please maven doesnt see and run junit4 tests in springboot please help, I have tried different configurations, please if anyone has done this before
    🚓 3
    :kotlin-flag: 2
    n
    • 2
    • 1
  • n

    nathan

    09/21/2020, 11:53 PM
    so im trying to have a one to many and a many to one in the dto. should i create a separte dto for postmapping?
    k
    d
    • 3
    • 3
  • n

    nathan

    09/29/2020, 2:12 AM
    does it matter if i use a data class or class for my entity
    k
    • 2
    • 1
  • d

    Dsittel

    09/29/2020, 7:23 AM
    hi guys i need to set based on a profile a environment variable (here https_proxy) for local development. any best practise for it ? (my idea so far is to set it within a @Configuration in the init block with ProcessBuilder, but no luck so far 😞 )
    t
    • 2
    • 11
  • t

    thanksforallthefish

    10/08/2020, 11:20 AM
    consider introducing proper tracing, not sure how it works with coroutines but it would be a better solution imo: https://spring.io/projects/spring-cloud-sleuth
    ☝️ 2
    e
    c
    +2
    • 5
    • 9
  • y

    Yevgeni Liskovich

    10/11/2020, 10:02 AM
    Hi, does spring MVC support kotlinx.serialization library ? if yes, where can i find example using it instead of Jackson ?
    c
    • 2
    • 2
  • n

    nathan

    10/13/2020, 4:18 AM
    is there ever a reason to use mutable list vs list in spring boot:?
    e
    t
    • 3
    • 4
  • s

    sdeleuze

    10/13/2020, 5:09 PM
    https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1602608934099100
    :kotlin: 6
    🎉 9
    g
    • 2
    • 7
  • w

    wakingrufus

    10/15/2020, 4:17 PM
    so is there something in spring-init that looks like
    fun makeFunctional(Class<?> configClass): (GenericApplicationContext) -> Unit
    ?
    • 1
    • 1
  • b

    bjonnh

    10/15/2020, 4:37 PM
    Is that kofu or it that part of spring boot now?
    d
    • 2
    • 9
  • j

    Jonas Bark

    10/15/2020, 4:46 PM
    Looking forward to the coroutine support in Spring MVC - We can then finally get rid of our
    runBlocking
    "workaround" - thanks @sdeleuze ! Less Kotlin, probably more about Spring itself: We're also using functional routing for a year now and we're very happy with it. The only thing I miss is support for server side events for Spring MVC projects. The functional routing receives a
    ServerRequest
    and expects a
    ServerResponse
    in return but I don't see a way to incorporate to respond with the SseEmitter object that is used for SSE on Spring MVC. Am I missing something or should I open a ticket?
    👍 1
    s
    • 2
    • 11
  • g

    gbaldeck

    10/16/2020, 5:25 PM
    is Exposed the recommended ORM for Kotlin + Spring?
    e
    j
    c
    • 4
    • 10
  • t

    thanksforallthefish

    10/20/2020, 5:58 AM
    I am not sure how to look for this info without going through github issues, so maybe someone knows and can save me some time. assuming I have something like
    class MyRestRepresentation(@get:NotBlank val notBlank: String)
    and someone makes an http call like
    POST { notBlank: null }
    kotlin will throw an exception (jackson will actually) before validation happens. this messes up the error response a bit, since with javax validation we get a nice path to the property that fails validation oob, while otherwise we probably need to do it manually, if at all possible. is Spring working on something like doing validation before before or some other approach or is my best option to declare
    notBlank
    as
    String?
    and just read it as
    notBlank!!
    ?
    k
    j
    • 3
    • 5
  • d

    Daniel Imber

    10/21/2020, 8:29 AM
    Hi. I'm using Spring Webflux and have controllers with suspending functions. I'd like to have all of those controller functions invoked with a coroutine that has an element within the coroutine context. The best I can think of so far is to manually add the context element as
    withContext
    inside each and every controller function - something like this:
    @GetMapping("/foo")
        suspend fun getFoo(): Foo {
            withContext(SomeCoroutineContextElement()) {
                TODO("Do something")
            }
        }
    Is there a better way - i.e. a way to add the context across all controller functions, so I don't need to litter every one of them with
    withContext
    ?
    t
    b
    • 3
    • 5
  • h

    hooliooo

    10/23/2020, 12:56 PM
    I’m having trouble integrating Flux into my codebase:
    val inputStream: InputStream = URL(attachmentURL).openStream()
    val buffer = DataBufferUtils.readInputStream(
        { inputStream },
        DefaultDataBufferFactory(),
        8192
    )
    I’ve integrated the following dependency into my project:
    implementation(group = "io.projectreactor", name = "reactor-core", version = "3.3.10.RELEASE")
    But i’m getting this error:
    Cannot access class 'reactor.core.publisher.Flux'. Check your module classpath for missing or conflicting dependencies
    highlighted on readInputStream Am I missing something?
    a
    • 2
    • 10
  • s

    sdeleuze

    10/28/2020, 7:41 AM
    https://twitter.com/sdeleuze/status/1321355855619624961?s=21
    👍 1
    🙏🏻 1
    💯 2
    :kotlin-flag: 1
    🎉 7
    n
    t
    t
    • 4
    • 12
  • n

    nfrankel

    10/29/2020, 7:11 PM
    now i want to play with coroutines and change my
    router
    to a
    corrouter
    but the latter expects a
    ServerResponse
    , not a
    Mono<ServerResponse>
    every example i see the function that generates/read the data is
    suspend
    and returns
    T
    so shall i understand in that case,
    corrouter
    is not a good fit? or did i miss something?
    r
    • 2
    • 6
  • r

    ReddyTintaya

    11/03/2020, 2:48 PM
    Hi, i have Exceptions defined like this
    const val reason = "store not found"
    @ResponseStatus(code = HttpStatus.NOT_FOUND, reason = reason)
    class StoreNotFoundException : RuntimeException()
    but i want to log the error whenever its been throw
    const val reason = "store not found"
    @ResponseStatus(code = HttpStatus.NOT_FOUND, reason = reason)
    class StoreNotFoundException : RuntimeException(){
        init {
            warningLog(reason)
        }
    
        companion object {
            private val logger = LoggerFactory.getLogger(CustomException::class.java)
            fun warningLog(message: String) {
                logger.warn(message)
            }
        }
    }
    i've implemented like this Since i have a lot of exceptions defined like this and i want to have the log whenever one is threw, how can i generalize this behavior? how can i write a CustomException?
    n
    k
    • 3
    • 11
  • t

    Timur Atakishiev

    11/09/2020, 4:17 AM
    Hi guys, is it possible to use kotlinx serialisation with spring boot?
    d
    s
    • 3
    • 3
  • s

    speed_star

    11/10/2020, 1:33 PM
    Hi. What does
    @EnableWebMvc
    exist for? 🤔 I used this annotation. However, when I added
    @EnableWebMvc
    to some
    Configuration
    , the other
    Configuration
    seemed to be disabled...
    s
    • 2
    • 2
  • s

    speed_star

    11/10/2020, 11:11 PM
    I built API by using
    @RestController
    . And I called GET API via curl command with multibyte character query param. But I received 400 error (The valid characters are defined in RFC 7230 and RFC 3986). Do I need to set some Spring Boot config?
    k
    • 2
    • 3
Powered by Linen
Title
s

speed_star

11/10/2020, 11:11 PM
I built API by using
@RestController
. And I called GET API via curl command with multibyte character query param. But I received 400 error (The valid characters are defined in RFC 7230 and RFC 3986). Do I need to set some Spring Boot config?
Request was success when I use
--data-urlencode
option for curl command 🤔
k

kqr

11/11/2020, 7:23 AM
how is this related to kotlin?
☝️ 1
s

speed_star

11/11/2020, 7:26 AM
Ah, this issue is related to Spring, not kotlin. Maybe I should post question on other place such as stackoverflow 😓
👍 2
View count: 4