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
  • t

    Tim Schraepen

    06/24/2019, 7:56 AM
    Had one issue with spring data, where I was trying to mock repository.findByIdOrNull, which is an extension function, and I regretted not wrapping spring data repositories in my own interfaces. Is there a best practice for that other than wrapping?
    s
    • 2
    • 1
  • j

    Jukka Siivonen

    06/24/2019, 9:52 AM
    Is there any way to prevent Jackson from de-serializing nulls to non-nullable list, for example I have comments: List<String> and payload comments: [null, null] gives me list of nulls. Or maybe I'm missing something here
    s
    • 2
    • 2
  • a

    ahulyk

    06/26/2019, 9:36 AM
    Hi! What is the best practice of using
    data class
    as
    Entity
    ?
    t
    c
    +2
    • 5
    • 6
  • w

    wakingrufus

    06/26/2019, 9:49 PM
    I built a POC at hack week at my work this week using KoFu and Flows. I can't wait until this stuff is mainstream 🙂
    👍 2
    e
    • 2
    • 4
  • j

    Jonatas

    06/28/2019, 2:33 PM
    Hi! Does anyone using a framework with Springboot 2 + Kotlin for feature toggle? I see this https://www.togglz.org, but I found some problems for Kotlin usage…
    l
    b
    h
    • 4
    • 4
  • m

    M1heng

    07/02/2019, 9:11 AM
    My group is planning to rebuild our backend service with Spring, and Kotlin seems a good option. So is there any advice?
    :stackoverflow: 1
    👍 1
    s
    d
    +5
    • 8
    • 15
  • s

    sdeleuze

    07/08/2019, 2:03 PM
    Or a custom one?
    t
    c
    • 3
    • 10
  • g

    Gerard Klijs

    07/14/2019, 8:50 AM
    Not sure if this is the correct place, but I have trouble getting ssl to work with a Kotlin Kafka Spring Boot application, using Spring Cloud Kafka Streams. A version using the same keystore and truststore but working with the Kafka Consumer and Kafka Producer does work. Also the ssl specific configurations seems correct from the logging. So it seems it's either Kotlin or Spring that does something different.
    • 1
    • 1
  • g

    gmariotti

    07/18/2019, 5:58 AM
    Hi everyone, quick question about the spring boot plugin. Is there any particular reason why the
    bootJar
    task has a dependency on
    kaptKotlin
    ? My understanding is that kapt is needed only for the metadata generation for the ide, am I wrong?
    c
    s
    • 3
    • 6
  • s

    Soren Valle

    07/18/2019, 9:32 PM
    I'm new to Kotlin and trying to figure things out. Do you need to
    .registerModule(KotlinModule())
    some how to get spring rest controller end points to deserialize the request body?
    s
    • 2
    • 2
  • x

    xenoterracide

    07/25/2019, 6:04 PM
    asking because it doesn’t seem to be, I’m ending up with this ….
    Parameter 2 of constructor in com.potreromed.gateway.usecase.InitialFoleySetupApplicationService required a bean of type 'com.potreromed.gateway.model.PatientService' that could not be found.
        Action:
        Consider defining a bean of type 'com.potreromed.gateway.model.PatientService' in your configuration.
    `
    j
    s
    • 3
    • 11
  • c

    Czar

    07/29/2019, 12:38 PM
    I'm trying to use spring-boot's configuration meta-data with spring boot 2.1.6 and kotlin: build.gradle.kts
    plugins {
    	id("org.springframework.boot") version "2.1.6.RELEASE"
    	id("io.spring.dependency-management") version "1.0.7.RELEASE"
    	val kotlinVersion = "1.3.41"
    	kotlin("jvm") version kotlinVersion
    	kotlin("plugin.spring") version kotlinVersion
    	kotlin("kapt") version kotlinVersion
    }
    dependencies {
    	kapt("org.springframework.boot:spring-boot-configuration-processor")
    	implementation(kotlin("reflect"))
    	implementation(kotlin("stdlib-jdk8"))
    	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    	//...
    }
    application.yml
    security:
      csrfEnabled: true
      token.writer.secret: h2l89efhlwskiehf89o23fhnsldhf89023
    usage of
    secret
    in a class:
    @ConfigurationProperties(prefix = "security.token.writer")
    class TokenBasedAuthenticationFilter {
    	private lateinit var secret: String
    	//...
    There is no metadata or autocomplete and IntelliJ shows
    Cannot resolve configuration property 'security.token.writer.secret'
    warning Am I missing something or is it a bug/limitation?
    l
    • 2
    • 8
  • f

    Fabian

    07/30/2019, 2:47 PM
    BTW as far as a understand, spring generates a proxy, and catches exceptions coming from methods/classes annotated with
    @Transaction
    to _commit_/_rollback_ the current transaction. However, I want my service layer to be something like
    Either<Error, A>
    t
    g
    • 3
    • 3
  • k

    KyooSik Lee

    08/01/2019, 10:50 AM
    Hi guys, Has anyone got this gradle error? I haven’t changed the
    build.gradle.kts
    file, but suddenly the gradle keeps giving me these import errors.
    Details: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find spring-context.jar (org.springframework:spring-context:5.2.0.BUILD-SNAPSHOT:20190801.073001-611).
    Searched in the following locations:
        <https://repo.spring.io/snapshot/org/springframework/spring-context/5.2.0.BUILD-SNAPSHOT/spring-context-5.2.0.BUILD-20190731.114634-606.jar>
    So I looked up the URL, and there is no spring-context-jar file that ends with
    20190731
    , but only
    20190801
    . Am I using outdated dependency? Following is my dependencies
    dependencies {
        implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
        implementation("org.jetbrains.kotlin:kotlin-reflect")
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    
        implementation("org.springframework.boot:spring-boot-starter-webflux:5.1.7.RELEASE")
    
        implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
        implementation("org.mongodb:mongodb-driver-reactivestreams")
    
        testImplementation("org.springframework.boot:spring-boot-starter-test") {
            exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
            exclude(group = "junit", module = "junit")
        }
        testImplementation("io.projectreactor:reactor-test")
    }
    Thanks for helping
    • 1
    • 1
  • l

    Lenny

    08/05/2019, 5:54 AM
    Is there any best practices to create in Kotlin Mappers between Entities and DTOs and vice versa? Or any should I use mapper libraries like Dozer or MapStruct?
    g
    j
    • 3
    • 5
  • r

    Robert Jaros

    08/05/2019, 2:46 PM
    Hello. Can I declare suspending methods in Spring components in the current Spring Boot version (2.1.6)?
    s
    • 2
    • 22
  • j

    Jonas Bark

    08/07/2019, 10:56 AM
    While digging deeper into Webflux, Coroutines and Spring Security I found that I can't access the ServerRequests pricinipal:
    reqeust.awaitPrincipal()
    always returns null. I'm using coRouter and all I do is:
    suspend fun categoriesGet(request: ServerRequest): ServerResponse {
           val principal = request.awaitPrincipal()
           println("PRINCIP: $principal")
    }
    when I use the standard-non-coroutine router I'm getting the expected result:
    fun hello(request: ServerRequest): Mono<ServerResponse> {
            return request.principal()
                .map { it.name }
                .flatMap { userName ->
                    ok().contentType(MediaType.APPLICATION_JSON)
                        .syncBody("Hello $userName")
                }
        }
    is this a bug?
    • 1
    • 1
  • r

    Robert Jaros

    08/07/2019, 1:58 PM
    What am I missing?
    s
    • 2
    • 11
  • s

    sdeleuze

    08/09/2019, 2:05 PM
    I may miss something, but with following Java interface:
    public interface Expression {
    
        @Nullable
    	Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException;
    
        @Nullable
    	<T> T getValue(EvaluationContext context, @Nullable Class<T> desiredResultType) throws EvaluationException;
    }
    And following Kotlin code
    val value = expression.getValue(context, String::class.java)
    , the method used is the first variant, not the second (with IDEA 2019.2 and Kotlin 1.3.41). Why?
    🤔 1
    m
    • 2
    • 10
  • c

    corneil

    08/12/2019, 2:44 PM
    I've create a project to reproduce the issue: https://github.com/corneil/spring-spel-kotlin-test
    s
    • 2
    • 11
  • s

    sdeleuze

    08/12/2019, 2:53 PM
    https://twitter.com/sdeleuze/status/1160927062049329154
    👍 6
    ❤️ 6
    🤩 3
    i
    d
    • 3
    • 4
  • r

    Robert Jaros

    08/12/2019, 4:09 PM
    Why can't I use
    .value("fieldName", v)
    for inserting using fluent API for R2DBC with
    v
    as nullable
    String?
    ? I have to check for
    null
    and use
    .nullValue("fieldName")
    instead. And it ruins the whole purpose of the fluent API. https://docs.spring.io/spring-data/r2dbc/docs/1.0.0.M2/reference/html/#r2dbc.datbaseclient.fluent-api.insert
    s
    • 2
    • 3
  • r

    Robert Menke

    08/25/2019, 6:02 AM
    Hey, I’m new to Spring. In order to get a
    DataJpaTest
    working I had to add the annotation
    @ComponentScan("com.my.package")
    to the class. Is this normal? If so, is it documented?
    @DataJpaTest
    @ComponentScan("com.my.package")
    class UserTest @Autowired constructor(
        private val userService: UserService
    ): AnnotationSpec() {
    
        @Test fun `Test that findByEmail handles capitalization inconsistencies`() {
            val user = User(email = "mYeMail@gmail.COm", password = "password")
            val persistedUser = userService.createUser(user)
            val email = "MyEmaIL@GMAil.Com"
            val found = userService.find(UserEmailIdentity(email))
            found.email shouldBe persistedUser.email
        }
    }
    j
    • 2
    • 2
  • r

    Robert Menke

    08/25/2019, 8:03 PM
    Is there a comprehensive sample project out there with webflux + netty + coroutines out there? I’m having a rough time getting a basic crud example working properly.
    s
    • 2
    • 2
  • s

    sdeleuze

    08/30/2019, 7:11 AM
    Contribution proposal: is there somebody interested to translate Spring Boot code sample to Kotlin like I did on the Spring Framework refdoc? The refdoc is long but there are not so many code samples so I do think it is doable in a reasonable amount of time.
    i
    c
    • 3
    • 38
  • s

    sdeleuze

    08/30/2019, 7:22 AM
    And the asciidoc extension should probably added to https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-docs/pom.xml
    c
    i
    • 3
    • 22
  • c

    Czar

    09/03/2019, 9:42 AM
    Hi, I'm trying to use spring-configuration processor in a library. It does not work. The setup is gradle 5.5.1, kotlin 1.4.50, Spring Boot 2.0.0.M5 To not hog the channel I moved the question to 😒tackoverflow: https://stackoverflow.com/questions/57769464/
    t
    s
    • 3
    • 12
  • l

    lex

    09/04/2019, 5:24 AM
    @sdeleuze hi, is there any plans to include https://github.com/konrad-kaminski/spring-kotlin-coroutine/blob/master/spring-webflux-kotlin-coroutine/src/main/kotlin/org/springframework/web/server/CoroutineWebFilter.kt into webflux?
    👍 1
    s
    d
    • 3
    • 8
  • s

    sdeleuze

    09/05/2019, 3:04 PM
    We don't change such default version during the development of a minor version of Boot, but yes you can.
    d
    • 2
    • 1
  • x

    xenoterracide

    09/09/2019, 4:35 PM
    not particularly related to kotlin but… does anyone know how I can get a transaction on a
    @SpringBootTest
    javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call
    i
    b
    • 3
    • 3
Powered by Linen
Title
x

xenoterracide

09/09/2019, 4:35 PM
not particularly related to kotlin but… does anyone know how I can get a transaction on a
@SpringBootTest
javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call
i

ienoobong

09/09/2019, 6:07 PM
You’ll need
@DataJpaTest
or similar
x

xenoterracide

09/09/2019, 6:09 PM
… yeah but that alone? won’t inject my services
b

Borgers Toon

09/10/2019, 7:40 AM
You can just add the
@Transactional
annotation on the test class/method. You'll get a test transaction you can commit/rollback manually: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/context/transaction/TestTransaction.html
View count: 9