Andrzej Sawoniewicz
06/09/2022, 2:56 PMMikhail
06/09/2022, 3:31 PM@Validated
on an interface. I prefer interface-driven controllersAndrzej Sawoniewicz
06/09/2022, 3:32 PMMikhail
06/09/2022, 3:46 PMConstraintViolationException
is not handled in the first requestNativeWebRequest
not as a constructor parameter, but define it as a parameter of a function that handles the request
look at my snippetAndrzej Sawoniewicz
06/09/2022, 3:57 PMMikhail
06/09/2022, 3:59 PMopen
do you use spring support plugin for kotlin?plugins {}
block of your build.gradle.kts
:
kotlin("plugin.spring") version "1.6.21"
Andrzej Sawoniewicz
06/09/2022, 4:01 PMMikhail
06/09/2022, 4:04 PMAndrzej Sawoniewicz
06/09/2022, 4:06 PMMikhail
06/09/2022, 4:08 PMplugins {
id 'org.springframework.boot' version '2.6.7'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.6.21'
id "org.jetbrains.kotlin.plugin.spring" version '1.6.21'
}
Andrzej Sawoniewicz
06/09/2022, 4:11 PMDiego Marzo
06/10/2022, 10:47 AM@Validated
@RestController
class TestController(private val request: NativeWebRequest)
If you have your spring plug there is no need of "open", no need for "@Autowired" and no need for the explicit "constructor"
I know it is not super important but you can remove some boilerplate