Questions tagged [spring-kotlin]
The spring-kotlin tag has no usage guidance.
26
questions
0
votes
1
answer
20
views
How to get requests path with unresolved variables in Spring WebFlux
I'm trying to get the request's path with unresolved path variables in a WebFilter. I know in SpringBoot Servlet version it is possible to do this by getting request's attribute with key org....
0
votes
1
answer
21
views
How to pass context back into the WebFilter when using SpringBootWebFlux with coroutines
Suppose I have the following application with a WebFilter and I'm trying to pass some context back from the controller into the filter.
@RestController
class MyController {
@PostMapping("/...
2
votes
0
answers
67
views
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, ...
0
votes
1
answer
279
views
Spring Security OAuth 2.0 Google: redirect to default URL after unauthorized request instead of requested URL
I'm using Spring Security OAuth 2.0 with Google as identity provider. I have problem with proper handling of session timeout and reauthentication.
Scenario:
Some request to REST API after session ...
0
votes
2
answers
413
views
Spring Kotlin @ConfigurationProperties for data class defined in dependency
I've got a library that has a configuration class (no spring configuration class) defined as a data class. I want a Bean of that configuration which can be configured via application.properties. The ...
0
votes
1
answer
199
views
Configuration DbSetup with Kotlin and Spring Boot
I'm developing Kotlin application with
gradle
Java 11
Spring Boot 2.3.6.RELEASE
DbSetup-kotlin:2.1.0
testcontainers:postgresql 1.15.0
After following this guide DbSetup Kotlin I'm facing problem ...
0
votes
1
answer
380
views
[R2DBC-Spring-Data-kofu]:Expressing distinct in criteria API
Hello I try to convert a jpql query to the criteria api.
the sql query is
SELECT COUNT(DISTINCT id) FROM `user` WHERE login != :anonymousUser
I've just succeed to reach this query with criteria
SELECT ...
0
votes
1
answer
896
views
Unable to write to Azure Service Bus Topic from Spring Boot Application using azure-servicebus-jms-spring-boot-starter
I am trying to push a message onto an azure service bus topic using JMS in Spring Boot.
As you can see below I have pulled in the dependancy for azure-servicebus-jms-spring-boot-starter
I have ...
0
votes
2
answers
1k
views
Spring boot + Kotlin + MongoDb: Cannot resolve reference to bean 'mongoTemplate' while setting bean property
I am trying to make a simple application using kotlin and spring boot which connects to mongodb and makes some operations there, however I am facing this issues.
If you guys want to see more details, ...
1
vote
1
answer
536
views
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)
...
0
votes
2
answers
2k
views
How to dynamically add key value pairs in Kotlin object?
I have Spring Boot REST api which returns JSON object like this -
{
"id": "1"
"timestamp": "2020-08-03T08:49:02.679+00:00"
"message": "...
0
votes
1
answer
506
views
Spring data/Hibernate: detached entity passed to persist
I get "detached entity passed to persist", but I do not understand, how the object in question can be in a detached state.
Here is some context first.
two JpaRepositorys for each users and ...
0
votes
2
answers
876
views
return Mono/Flux with 2 nested subscriptions
I need to return Mono / Flux for a function but this has 2 nested subscriptions. I am looking for a better solution to publish Mono/Flux only after this 2 subscription values are available then ...
0
votes
1
answer
246
views
Kotlin > Spring Boot > Using router DSL, POST Method body, unable to convert JSON to POJOs
I’m trying to build a Petstore Fullstack application using Kotlin Multiplatform. I’m using Spring Router DSL for defining rest endpoints. For the GET method, it worked fine. Then I started working on ...
0
votes
1
answer
1k
views
@EnableWebFlux on a WebFluxConfigurer does autoconfigure a ThymeleafViewResolver as expected
I'm building a REST api starting with spring-boot-starter-webflux, but I'd also like the app to serve a swagger UI using a webjar. I need to tweak how the swagger UI initializes, so I've made a @...
1
vote
1
answer
1k
views
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 ...
1
vote
0
answers
755
views
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 ...
2
votes
3
answers
463
views
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(
...
0
votes
0
answers
380
views
Request body is empty when no authentication is present for secure APIs
I am trying to log the request body on all requests in a spring boot reactive application secured with spring security. But I am running into an issue where the request body is logged only if the ...
2
votes
0
answers
393
views
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 ...
0
votes
1
answer
604
views
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 ...
1
vote
1
answer
1k
views
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, ...
1
vote
1
answer
997
views
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'...
2
votes
2
answers
1k
views
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
@...
2
votes
1
answer
1k
views
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 ...
1
vote
0
answers
393
views
Kotlin generic issue, should be subtype of Nothing
I'm writing a simple Spring test on Kotlin and have a compilation error with generics that I can't understand. The function is below:
@Test
fun actuatorRootReturnsOnlyAllowed() {
val expectBody:...