Questions tagged [spring-kotlin]
34 questions
4
votes
1 answer
Spring boot validate each string in a List (kotlin)
I'm struggling with validation in String Boot.
I have the following class in Kotlin:
class ListBlock(
@field:Size(max = 5)
val style: String,
@field:Valid
@field:Size(max = 10)
val items: List<@Size(max = 50)…

Aslak
- 109
- 8
4
votes
0 answers
How can I enable auto build and auto restart with spring boot kotlin intellij
I want to rebuild project automatically when i edit project files.
So, I tried spring-boot-devtools, and Intellij seettings.
I Checked this page.
Hoever, I always have to restart project manually when I edit files in spring boot project.
What is…

久保圭司
- 579
- 5
- 16
2
votes
1 answer
Spring in Kotlin: from 5.3 to 6.0 security Configuration
I'm facing lots of issues in doing Spring security configurations that I used to have in v5.3 applied in v6.
This is the file I had
@Configuration
@EnableWebSecurity
class WebSecurityConfiguration : WebSecurityConfigurerAdapter() {
@Autowired
…

Saher Al-Sous
- 517
- 4
- 15
2
votes
0 answers
RestTemplate to WebClient
I'm migrating usage of RestTemplate to WebClient, following is my existing RestTemplate code,
val restTemplate: RestTemplate
@Throws(KeyStoreException::class, NoSuchAlgorithmException::class, KeyManagementException::class)
get() {
…

Vignesh
- 3,571
- 6
- 28
- 44
2
votes
3 answers
How to register external annotation to be used by spring validation
I have a library that defines some annotations. This annotation can be added to my requests, I would like to glue that annotation to some custom Validator.
External lib
Annotation class
@Target(
AnnotationTarget.FUNCTION,
…

Mikooos
- 5,360
- 5
- 31
- 45
2
votes
2 answers
Spring Kotlin DSL: get all beans of certain type
Suppose I have an interface Yoyo and different realizations of this interface:
interface Yoyo {
fun haha() {
println("hello world")
}
}
@Component class Yoyo1 : Yoyo
@Component class Yoyo2 : Yoyo
@Component class Yoyo3 :…

maslick
- 2,903
- 3
- 28
- 50
2
votes
1 answer
Spring WebClient extract JsonPath value
I'm using Spring 5 WebClient test features and would like to extract body matched by the jsonPath expression but can't find any suitable way of doing it. For example (the code is in Kotlin but I hope this doesn't make any…

yyunikov
- 5,719
- 2
- 43
- 78
1
vote
1 answer
why doesn't spring boot 2.7.x use kotlin 1.7 or 1.8
I would like to come up with some empirical evidence for, or against, migrating spring boot 2.7.x to kotlin >= 1.7.x.
Looking at the spring boot documentation, kotlin version 1.6.21 is listed. However, in some of the spring examples listed, point…

Jolley71717
- 678
- 1
- 8
- 20
1
vote
2 answers
Spring Boot 3.0 with Jpa 3.1 instantiation in query not working
Since the upgrade to Spring Boot 3.0 following query is not working anymore:
@Query("""
select new com.example.OrderProductWithAmount(
op, sum(op.amount), sum(op.paidAmount)
)
from OrderProduct op
join…

kaulex
- 2,921
- 3
- 11
- 38
1
vote
1 answer
kotlin delegated field is always null when loaded from hibernate
I'm trying to do something that would be simple as hell in java but kotlin came to make it a nightmare.
interface IChargeableDTO{
var name: String
var ref: String
var priceCents: Int
var maxInstallments: Int
var gateway:…

Rafael Lima
- 3,079
- 3
- 41
- 105
1
vote
1 answer
Can we build a full stack webapp with kotlin?
Kotlin official documentation tells that it supports web development. And its replacement for java. I am trying to build a web application using Kotlin. So far I read so many blogs, courses and videos in YouTube but I did not succeed coming up with…

Sundar Nivash
- 306
- 6
- 25
1
vote
0 answers
Spring Boot Gradle Driver for test database [h2] is not available
I am using H2 database with Spring Boot project. I have runtime dependency on h2 in build.gradle.kts file, but it is not able to find the driver.
Caused by: java.lang.IllegalStateException: Driver for test database type [H2] is not available
at…

Abdul Fatah
- 463
- 6
- 23
1
vote
1 answer
Is there plans to add Kotlin support for the Spring Tools Suite?
I want to use Kotlin with the Spring Tools suite plugin for VSCode but it only supports Java (For things like intellisense).
I know I should just use intelliJ and I will for now but I program in a lot of different languages daily and I would like to…

ChrisAtMachine
- 11
- 1
1
vote
1 answer
Why queryForObject Kotlin extension func returns nullable T? if it actually will throw EmptyResultDataAccessException?
Using Kotlin and Spring 5 for some simple project.
I would like to get single record from database by id using queryForObject.
My query is a 'simple select by id':
jdbc.queryForObject("select id, name from example where id = ?", id)
{ rs:…

Kirill
- 6,762
- 4
- 51
- 81
1
vote
1 answer
Spring @RestController is not mapping URL with Kotlin
I've created a Kotlin gradle project using Spring IO.
Created a Controller class with a method to return a String.
When I build and run the project I'm getting 404 error. Looking at the logs I don't see the URL mapping to the method.
If I use…

chattambigeek
- 101
- 4