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

    hho

    05/28/2018, 8:45 AM
    You can implement any method in an abstract class ¯\_(ツ)_/¯
    z
    c
    +2
    • 5
    • 9
  • m

    Michael

    05/30/2018, 3:22 PM
    I’m trying to write a ConstraintValidator in kotlin, and not finding any good examples. In java you define an @interface, and then reference a class that extends Constraint Validator. In kotlin, you do an
    annotation class
    instead - but is it otherwise the same, a separate class that the annotation class points to? at first I thought maybe I would just put the behavior in the
    annotation class
    - but it seems problematic to extend
    ConstraintValidator
    since that needs to be typed as the annotation type. This is not my usual area, so I’m just kind of trying things.
    l
    • 2
    • 5
  • s

    snowe

    05/30/2018, 3:33 PM
    Anybody have an answer for my question about the
    jpa
    plugin with MappedSuperclass from a few days ago?
    d
    e
    • 3
    • 12
  • t

    TormentedDan

    05/30/2018, 10:02 PM
    Hello, everyone, I'm trying to set up spring security and I think I got it working but I'd like an efficient way to filter url patterns other than using antMatchers. I've seen some people use extended xml, but I'm unaware of exactly how to leverage this feature (Where should the file go, how should it be named, where can I find more docs about this feature?). Most importantly, I was curious if there was a dedicated DSL for spring security, similar to what
    router {}
    does, if there is I can't seem to find the docs. Can anyone here point me in the right direction?
    c
    l
    s
    • 4
    • 6
  • p

    pyryjook

    06/05/2018, 11:09 AM
    Hello! I have Kotlin/Spring Boot/JPA project that works when built on Maven, but when building and starting it using IntelliJ IDEA (OSX) get this error on start: `org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'SwaggerDocumentationConfig' may not be final. Remove the final modifier to continue.`` I have the newest IDEA with the newest Kotlin plugin installed. On top of that I have used
    kotlin-maven-plugin
    with
    all-open
    ,
    jpa
    ,
    spring
    , which works for Maven. Anyone had similar problem? I’ve been Googling for the issue and found similar errors and solutions for those but none worked for me. My colleague has the same problem. Thanks in advance!
    • 1
    • 1
  • s

    sdeleuze

    06/08/2018, 1:08 PM
    https://kotlinlang.slack.com/archives/C0B8RC352/p1528463309000468
    👏 11
    👍 7
    ❤️ 1
    c
    n
    +4
    • 7
    • 19
  • m

    Max Kramer

    06/10/2018, 1:28 PM
    Hi, I was wondering if anybody would be able to help with https://kotlinlang.slack.com/archives/C0B8RC352/p1528479490000152
    l
    • 2
    • 2
  • c

    Czar

    06/12/2018, 10:26 AM
    Hi, I've started looking at Spring-fu code, and immediately stumbled upon this. I commend the project developers on deciding to use tabs for indentation, but smart indent for arguments? Is this the recommended formatting for spring-fu? One of the benefits of using tab is customizable indent width without change in the source itself, smart-indent kills this benefit. Look at the part of spring-fu code on the screenshot

    https://k62.kn3.net/B/E/A/3/4/7/558.png▾

    2) is with indent settings in IntelliJ set to 4-4-8 (probably what spring-fu original devs have) 1) is same code without any change with 2-2-4 setting in IntelliJ 3) is proposed best practice, if written that way, code will look good regardless of settings. (sorry, I screwed up numbering while editing screenshot, that's why my comments are 2 -> 1 -> 3 😄 ) Also please note that 3) is recommended by official kotlin style guide: https://kotlinlang.org/docs/reference/coding-conventions.html#function-formatting Even though being fan of using tabs I ignore parts of the guide, mostly it is sound and logical, including parameters formatting recommendation mentioned above. I also see that there are unneeded double indents e.g.
    application {
    	logging {
    		logback = logback {
    			rollingFileAppender(
    					file = File.createTempFile("mylog", ".txt"),
    					name = "MY_ROLLING",
    					pattern = "%d{yyyy-MM}",
    					fileNamePattern = "%i.gz",
    					maxFileSize = "2GB",
    					maxHistory = 11,
    					totalSizeCap = "1MB",
    					append = false
    			)
    		}
    	}
    }
    instead of
    application {
    	logging {
    		logback = logback {
    			rollingFileAppender(
    				file = File.createTempFile("mylog", ".txt"),
    				name = "MY_ROLLING",
    				pattern = "%d{yyyy-MM}",
    				fileNamePattern = "%i.gz",
    				maxFileSize = "2GB",
    				maxHistory = 11,
    				totalSizeCap = "1MB",
    				append = false
    			)
    		}
    	}
    }
    From this I conclude that JetBrains' Kotlin style formatter is not enabled at all. Which is disappointing if it was a conscious decision.
    s
    • 2
    • 8
  • p

    poohbar

    06/12/2018, 2:45 PM
    I use number 2) for methods and number 3) for classes... that numbering makes my head hurt hah
    c
    • 2
    • 1
  • m

    michael.barker

    06/12/2018, 6:23 PM
    Why not just use Kotlin's coding conventions for formatting? https://kotlinlang.org/docs/reference/coding-conventions.html#formatting
    c
    • 2
    • 2
  • l

    lewik

    06/12/2018, 7:01 PM
    How to use kotlin script as spring configuration? This will be type safe and able to change after deploy
    c
    s
    • 3
    • 4
  • s

    SackCastellon

    06/13/2018, 4:40 PM
    @sdeleuze The Coroutines webapp documentation link points to
    .../coroutines-webapp
    results in a 404 error, the right path is
    .../coroutine-webapp
    s
    • 2
    • 1
  • s

    sdeleuze

    06/14/2018, 10:28 AM
    If somebody want to start playing with Spring Fu internals, we have 2 easy issues ideal for contributing the first time: Undertow (https://github.com/spring-projects/spring-fu/issues/59) and Jetty (https://github.com/spring-projects/spring-fu/issues/60) server modules
    👍 1
    i
    r
    o
    • 4
    • 9
  • t

    tmg

    06/21/2018, 6:43 AM
    Oh yeah, forgot about defaults. I didn't though of that because default should be at the end of the list otherwise if you want to omit those you must use the names of the other parameters. But it doesn't really make a difference if
    id
    is the first or last field. Thanks Alexander!
    c
    • 2
    • 1
  • c

    Czar

    06/21/2018, 12:43 PM
    When you have only one constructor in a Spring component, the framework tries to autowire that constructor.
    n
    • 2
    • 2
  • n

    nfrankel

    06/23/2018, 10:03 PM
    if i nest the
    router
    block inside the
    bean
    i can write:
    bean {
            val personHandler = PersonHandler(ref())
            router {
                "/person".nest {
                    GET("/", personHandler::readAll)
                    GET("/{id}", personHandler::readOne)
                }
            }
        }
    it compiles but the route is not found at runtime
    s
    • 2
    • 2
  • t

    tgirard12

    06/25/2018, 7:57 AM
    @nfrankel have you try this : https://stackoverflow.com/a/46033685
    n
    • 2
    • 1
  • s

    sdeleuze

    06/25/2018, 10:01 PM
    @nfrankel Did you solve your issue?
    n
    • 2
    • 1
  • s

    sdeleuze

    06/25/2018, 10:04 PM
    https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/functional/Beans.kt#L18-L20 is indeed quite close to what you are trying to achieve
    n
    • 2
    • 6
  • f

    fitzoh

    06/26/2018, 12:17 AM
    @sdeleuze I’ve been curious about something… has there been much internal discussion on the spring team about micronaut and the AOT model?
    s
    • 2
    • 1
  • m

    mp

    07/03/2018, 10:43 AM
    Hi there I have question about contract control for my controller. My entity have 2 required fields and 2 optional but all of them are notnullable When client send request with
    name=null
    or
    description=null
    , processing fails onto json
    MissingKotlinParameterException: Instantiation of [simple type, class com.norselab.ivaldi.model.category.Category] value failed for JSON property name due to missing (therefore NULL)
    but if missed optional (not description=null, but missed in request from client) field - it instantiated from default value, in the same if missed required field also comes miss json error and status 500, but probably good is to have status 400 Is this expected behavior? Or I have miss configuration or even miss understanding
    data class Category(
        val externalId: String = UUID.randomUUID().toString(),
        val name: String,
        val description: String = "",
        val parent: String = ""
    )
    
    class Controller {
        @PostMapping("")
        fun createCategory(@RequestBody newCategory: Category) {}
    }
    or this is bad practice
    e
    • 2
    • 4
  • p

    poohbar

    07/04/2018, 6:11 PM
    I have this:
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/>
    </parent>
    n
    l
    • 3
    • 4
  • б

    Бежан Александр

    07/16/2018, 3:18 PM
    It can’t create class that doesn’t have noarg constructor
    s
    • 2
    • 2
  • c

    ciferkey

    07/16/2018, 6:53 PM
    Hello, I'm trying to modify the reactive-webapp.zip for Spring Fu. The example gradle config already includes spring-fu-logging-logback and spring-fu-webflux-netty. However when I try to include spring-fu-webflux-jackson it fails to resolve the dependency. Any thoughts on what configuration change is needed to get it to resolve? Could this be related to the module being recently renamed?
    s
    • 2
    • 2
  • s

    sdeleuze

    07/20/2018, 4:43 PM
    In a nustchel getting bean references must be done in the lambda that create a bean
    c
    • 2
    • 1
  • c

    corneil

    07/22/2018, 7:44 PM
    It looks like Spring Fu is going to provide great performance. Have a look at the test project at https://github.com/corneil/reactive-spring-5
    s
    • 2
    • 1
  • k

    kenkyee

    07/23/2018, 6:09 PM
    What doesn't make sense is Spring MVC being faster than Kotlin Webflux...Webflux should be faster as loads increase but it's consistently slower in that benchmark...
    t
    c
    g
    • 4
    • 9
  • a

    avolkmann

    07/24/2018, 12:04 PM
    Is there any more documentation as to how the bootJar process works? I read through the gradle plugin docs here https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/ and the api already
    c
    • 2
    • 3
  • g

    Gabriel Machado

    07/27/2018, 5:10 PM
    Is there a recommended modifier for autowired variables?
    lateinit var
    or a null initialized
    val
    z
    s
    • 3
    • 4
  • s

    sendilkumarn [JHipster]

    08/02/2018, 1:49 PM
    One question,
    fun findAll(pageable: Pageable): Page<AuditEvent> {
            return persistenceAuditEventRepository.findAll(pageable)
                .map{ auditEventConverter.convertToAuditEvent(it) }
    }
    return userByEmailFromDatabase
                        .map { createSpringSecurityUser(login, it) }
                        .orElseThrow { UsernameNotFoundException("User with email " + login + " was not found in the database") }
    What is wrong with the above 2 snippets? Strangely it is working on the IntelliJ but in terminal it fails with the following
    kotlin/main/com/mycompany/myapp/service/AuditEventService$findAll$1.class
        undeclared type variable: U
        Please remove or make sure it appears in the correct subdirectory of the classpath.
    Any idea or suggestions?
    l
    • 2
    • 7
Powered by Linen
Title
s

sendilkumarn [JHipster]

08/02/2018, 1:49 PM
One question,
fun findAll(pageable: Pageable): Page<AuditEvent> {
        return persistenceAuditEventRepository.findAll(pageable)
            .map{ auditEventConverter.convertToAuditEvent(it) }
}
return userByEmailFromDatabase
                    .map { createSpringSecurityUser(login, it) }
                    .orElseThrow { UsernameNotFoundException("User with email " + login + " was not found in the database") }
What is wrong with the above 2 snippets? Strangely it is working on the IntelliJ but in terminal it fails with the following
kotlin/main/com/mycompany/myapp/service/AuditEventService$findAll$1.class
    undeclared type variable: U
    Please remove or make sure it appears in the correct subdirectory of the classpath.
Any idea or suggestions?
l

lex

08/03/2018, 5:24 AM
what you mean "in termnal"?
s

sendilkumarn [JHipster]

08/03/2018, 8:25 AM
running
.gradlew
in a terminal (command line)
l

lex

08/03/2018, 9:12 AM
does IDEA use gradle wrapper too?
s

sendilkumarn [JHipster]

08/03/2018, 11:15 AM
yeah
Oops I am wrong here, Actually in IntelliJ I just run the Spring boot's main function But the gradlew script is not working when we mix Java and Kotlin. Is there any special configuration that we need to do in build.gradle when mixing java and kotlin
l

lex

08/07/2018, 4:17 AM
no
s

sendilkumarn [JHipster]

08/07/2018, 4:26 AM
This is super interesting (as well as annoying) why does JavaCompile step worries about Kotlin’s compiled class ? If I split the code with an if … else it is working.
View count: 3