Home > Blockchain >  Error in Java Import statement "The import javax.validation.constraints.NotNull and NotEmpty ca
Error in Java Import statement "The import javax.validation.constraints.NotNull and NotEmpty ca

Time:10-25

I am new to Java and Spring Framework. After developing Spring boot project, I found the following errors in class :

Cannot resolve symbol 'validation'

This is the pom.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.5</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Can someone guide me on what I am doing and how it can be rectified?

Thanks in advance

CodePudding user response:

Please add below dependency in pom.xml under tag and try again.

<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-validation</artifactId> 
</dependency>

CodePudding user response:

You need to add also in your dependencies.

   <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
    </dependency>

the version could be resolved from spring-boot-starter-parent.

  • Related