dodalovic
11/11/2020, 2:48 PMkotlin
@ConstructorBinding
@ConfigurationProperties("company")
class UsersProperties(val users: Map<String, User>) {
data class User(
val password: String,
val companyName: String,
val accounts: List<String>
)
}
and this in my application.yaml
yaml
company:
users:
<mailto:admin@email.com|admin@email.com>:
password: admin
companyName: Company 1
accounts: [ "ACC1", "ACC2" ]
<mailto:user@user.com|user@user.com>:
password: user
companyName: Company 2
accounts: [ "ACC3", "ACC4" ]
spring complains that users
property can't be null
Any idea?
Thanks in advancedodalovic
11/12/2020, 10:45 AMcoRouter
) with coroutines ... Can someone point me to Spring security configuration for such a stack? Thanks!
I'm using pretty much the latest Spring BootEvgeniy Zaharov
11/12/2020, 11:51 AMval context = Mono.deferWithContext { ctx -> Mono.just(ctx) }.awaitFirst()
. Is it a right solution ?Robert Jaros
11/12/2020, 6:19 PMRobert Jaros
11/12/2020, 6:19 PMJonas Bark
11/12/2020, 9:09 PMclass reactor.core.publisher.MonoOnErrorResume cannot be cast to class org.springframework.web.servlet.function.ServerResponse (reactor.core.publisher.MonoOnErrorResume and org.springframework.web.servlet.function.ServerResponse are in unnamed module of loader ‘app’)Anyone else got this during unit tests when using runBlocking after updating to Spring Boot 2.4.0? I’m currently investigating why all tests fail once runBlocking is used.
jbnizet
11/15/2020, 8:00 PMJúlio Santos
11/19/2020, 5:53 PMrajesh
11/20/2020, 6:56 AMnull
in UsernamePasswordAuthenticationToken(userDetails, "", userDetails.authorities)
gives error as authorities can not be null . Any tutorial or help is appreciated.Qria
11/21/2020, 2:47 PMKush Patel
11/23/2020, 3:49 AMindex.html
when I visit <http://localhost:8080/index.html>
but what I would like to do is render the index.html
when I visit <http://localhost:8080/>
. Any insight would be helpful. Thanks!gbaldeck
11/24/2020, 8:44 PMReddyTintaya
11/25/2020, 7:21 PMManuel Lorenzo
11/27/2020, 8:55 AMPhilipp Mayer
11/27/2020, 8:12 PM@Serializable
class RouteDto(
val id: Int? = null,
val template: Template?,
val server: Server?,
val variables: List<Variable>,
val name: String,
val active: Boolean,
val profile: Profile,
val description: String
)
And I have the following endpoint:
@RestController
@RequestMapping("/routes")
class RouteController(
@PostMapping("/new")
fun createRoute(routeDto: RouteDto): ResponseEntity<RouteDto?> {
val route = saveRouteService.saveRouteFrom(routeDto)
val dto: RouteDto = route.id?.toDto() ?: return ResponseEntity.unprocessableEntity().build()
return ResponseEntity.ok(dto)
}
Now I just wanted to call it like that with mockMvc:
@Test
fun `should create a route`() {
val dto = RouteDto(null, null, null, listOf(),"testDto", true, Profile.DEV, "should create a route test")
<http://mockMvc.post|mockMvc.post>("/routes/new") {
contentType = MediaType.APPLICATION_JSON
content = Json.encodeToString(dto)
}.andExpect {
status { is2xxSuccessful() }
}
}
However, I get the following Warning:
DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'routeDto' on field 'active': rejected value [null]; codes [typeMismatch.routeDto.active,typeMismatch.active,typeMismatch.boolean,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [routeDto.active,active]; arguments []; default message [active]]; default message [Failed to convert value of type 'null' to required type 'boolean'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [null] to type [boolean] for value 'null'; nested exception is java.lang.IllegalArgumentException: A null value cannot be assigned to a primitive type]]
Spring seems to fail at reading the Boolean value active
, which is actually correctly serialized:
MockHttpServletRequest:
HTTP Method = POST
Request URI = /routes/new
Parameters = {}
Headers = [Content-Type:"application/json;charset=UTF-8", Content-Length:"136"]
Body = {"template":null,"server":null,"variables":[],"name":"testDto","active":true,"profile":"DEV","description":"should create a route test"}
Session Attrs = {}
It would be great if someone could point me in a helpful direction. Thanks in advance!thana
12/08/2020, 12:44 PMManuel Lorenzo
12/09/2020, 9:01 AMapplication.properties
it works 😞. Also, I’d like to insert some data into a table in that DB as soon as the app is started. I created some insert statements into a data.sql
file in the resources
file but I nothing is inserted (edited)Subhanshu
12/10/2020, 5:02 PMthana
12/11/2020, 11:34 AMSaharath Kleips
12/15/2020, 6:01 PMReactiveRedisTemplate
from the reactive Redis starter.
val template = ReactiveStringRedisTemplate(connectionFactory)
template.opsForValue().get("123").subscribe { println("get: $it") } // works! prints: "get: ..."
runBlocking {
val value = template.opsForValue().get("123").awaitFirst() // fails! connection timeout????
println("get: $value")
}
I’m not sure if this is a coroutines specific issue but awaitFirst
works when converting other fluxes.manlan
12/16/2020, 3:18 PMthana
12/16/2020, 4:11 PMtvtan
12/17/2020, 10:44 AMInstant
or LocalDateTime
to mysql Datetime and Timestamp?vilmos.nagy
12/17/2020, 4:38 PM@Transactional
annotation to one of my spring service's method.
After the annotation is added some classCastException is thrown, see the details here: https://stackoverflow.com/questions/65331458/classcastexception-monoonerrorresume-cannot-be-cast-to-class-io-ebean-query
Is there a howto on how to use the kotlin-coroutines with spring transactions? thanks,tvtan
12/18/2020, 3:20 AMWebFilter
with kotlin coroutines, currently the only way I can run suspend function
in filter
function is using runBlocking
. Is there a better way for calling a suspend function in that case?sdeleuze
12/18/2020, 2:44 PMmarzelwidmer
12/18/2020, 5:31 PM1.4.21
and spring 2.4.1
on place.. with kotlin gradle .kts
I am new in gradlenathan
12/20/2020, 1:57 AMŁukasz Bednarczyk
12/21/2020, 7:36 PMIvan Pavlov
12/24/2020, 3:38 PMhttp.cors().configurationSource { CorsConfiguration().applyPermitDefaultValues() }
However MVC dsl for CORS doesn't contain an ability to set configuration source (CorsDsl
). I can see that in WebFlux version (ServerCorsDsl
) there is
var configurationSource: CorsConfigurationSource? = null
Does anyone know why there is no such property for MVC?Ivan Pavlov
12/24/2020, 3:38 PMhttp.cors().configurationSource { CorsConfiguration().applyPermitDefaultValues() }
However MVC dsl for CORS doesn't contain an ability to set configuration source (CorsDsl
). I can see that in WebFlux version (ServerCorsDsl
) there is
var configurationSource: CorsConfigurationSource? = null
Does anyone know why there is no such property for MVC?Joris PZ
12/26/2020, 8:04 AM@Bean
fun corsConfigurationSource(): CorsConfigurationSource {
//
}
Ivan Pavlov
12/26/2020, 8:08 AMWebSecurityConfigurerAdapter()
and using spring-security-config 5.4.1. Are you using it the same way?Joris PZ
12/26/2020, 11:45 AM@Bean
that exposes a CorsConfigurationSource
, but this compiles for me)
@Configuration
class APISecurityConfig() : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http
.antMatcher("/api/**")
.cors().configurationSource { CorsConfiguration().applyPermitDefaultValues() }.and()
// ETC
}
Ivan Pavlov
12/26/2020, 11:47 AMhttp.cors().configurationSource { CorsConfiguration().applyPermitDefaultValues() }
with dsl:
http {
cors {
//set configuration source here
}
}
Sorry if my original question was written badly 🙂Joris PZ
12/26/2020, 11:47 AM