问题
I can't import that simple library, i have all jar files, also i tried Ivalidate Caches / Restart. Maybe i have to add validation to build path, but i don't know to which file.
回答1:
Got it.
- File -> Project Structure
- In Modules click Dependecies, then click green "+" on the right side
- Click JARs or directiories... and add JAR files
Click OK
THEN:
- File -> Project Structure
- In Artifacts click FIX button on right bottom size
- Click OK
回答2:
What build tool do you use? You obviously forgot to declare your dependencies, that's why IDEA doesn't know where to look for the classes you are trying to import.
回答3:
You just need to add the dependency Validation API in the pom.xml:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.0.Final</version>
</dependency>
Links: https://www.baeldung.com/javax-validation
回答4:
You just need to add spring-boot-starter-validation
dependency in build.gradle
file
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
}
回答5:
If you get this error after attempting to import a Maven project, it may be that you need to check "Import Maven projects automatically" in the Import Project wizard. Without that the IntelliJ build may not be able to locate Maven dependencies, even if they are declared in pom.xml files.
来源:https://stackoverflow.com/questions/45035685/cannot-import-javax-validation-constraints-in-intellij-idea