英文:
Unresolve error for Validators in Spring boot - Kotlin
问题
user.controller
fun createUser(@Valid() @RequestBody payload: Map<String, String>, @RequestHeader(value = "session") session: String): String {
/// code
}
build.gradle
implementation "org.springframework.boot:spring-boot-starter-web"
I am getting an error "Unresolved reference: Valid"
I have added the starter project for the hibernate validator
I have no clue what I am missing?
英文:
user.controller
fun createUser(@Valid() @RequestBody payload: Map<String, String>, @RequestHeader(value = "session") session: String): String {
/// code
}
build.gradle
implementation "org.springframework.boot:spring-boot-starter-web"
I am getting an error Unresolved reference: Valid
I have added the starter project for the hibernate validator
I have no clue what I am missing?
答案1
得分: 2
验证在最近版本的Spring Boot中不再包含在内。
您必须添加 "validation-starter" 库:
Maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Gradle:
implementation("org.springframework.boot:spring-boot-starter-validation")
英文:
Validation is no more included in recent versions of Spring Boot.
You must add "validation-starter" library:
Maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Gradle:
implementation("org.springframework.boot:spring-boot-starter-validation")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论