[英]Cannot import javax.validation.constraints in IntelliJ IDEA
Got it.知道了。
Click OK点击确定
THEN:然后:
You just need to add the dependency Validation API in the pom.xml :您只需要在pom.xml中添加依赖验证 API :
<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.0.Final</version> </dependency>
Links: https://www.baeldung.com/javax-validation链接: https ://www.baeldung.com/javax-validation
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.
你显然忘了声明你的依赖关系,这就是为什么 IDEA 不知道在哪里寻找你试图导入的类。
You just need to add spring-boot-starter-validation
dependency in build.gradle
file你只需要在
build.gradle
文件中添加spring-boot-starter-validation
依赖
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
}
Try this,试试这个,
Step-by-step:一步步:
Open "build.gradle" file.打开“build.gradle”文件。 It's in your root folder project;
它在您的根文件夹项目中;
Include the line below inside "dependencies{ }": implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'在“dependencies{}”中包含以下行:实施组:'javax.validation',名称:'validation-api',版本:'2.0.1.Final'
Save and close build.gradle file;保存并关闭 build.gradle 文件;
Next, you will see a short notification on the top of your screen to "Load Gradle Changes".接下来,您将在屏幕顶部看到一条简短的通知“加载 Gradle 更改”。 Click on it.
点击它。
If you don't see any notification, click on Gradle side bar, and then click on "Reload All Gradle Projects".如果您没有看到任何通知,请单击 Gradle 侧边栏,然后单击“重新加载所有 Gradle 项目”。
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.如果您在尝试导入 Maven 项目后遇到此错误,可能是您需要在导入项目向导中选中“自动导入 Maven 项目”。 Without that the IntelliJ build may not be able to locate Maven dependencies, even if they are declared in pom.xml files.
否则 IntelliJ 构建可能无法找到 Maven 依赖项,即使它们是在 pom.xml 文件中声明的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.