未解决的 Spring Boot 中 Validators 的错误 – Kotlin

huangapple go评论86阅读模式
英文:

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&lt;String, String&gt;, @RequestHeader(value = &quot;session&quot;) session: String): String { 
    /// code
}

build.gradle

implementation &quot;org.springframework.boot:spring-boot-starter-web&quot;

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:

&lt;dependency&gt;
   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
   &lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&gt;
&lt;/dependency&gt;

Gradle:

 implementation(&quot;org.springframework.boot:spring-boot-starter-validation&quot;)

huangapple
  • 本文由 发表于 2020年10月2日 23:55:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/64174682.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定