简体   繁体   中英

Error in Java Import statement "The import javax.validation.constraints.NotNull cannot be resolved"

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class:

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

from Spring boot 2.3 version you have to add this dependency in your pom.xml

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

the web starters no longer contains the validation so you have to add it manually

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Iam new to Java and Spring Framework. After developing Spring roo project, I found following errors in class :

The import javax.validation.constraints.NotNull cannot be resolved

NotNull cannot be resolved to a type

Iam using STS 3.1.0.RELEASE

Can some one guide me what Iam doing and how it can be rectified.

Thanks in advance

Intellij solution: After pasting the code below you need to close intellij (entirely) then open again.

pasted the following:


    <dependency>
         <groupId>javax.validation</groupId>
         <artifactId>validation-api</artifactId>
         <version>1.0.0.GA</version>
    </dependency>

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
</dependency>

<dependency>
    <groupId>jakarta.validation</groupId>
    <artifactId>jakarta.validation-api</artifactId>
    <version>2.0.2</version>
</dependency>

there are also following versions there.

If you are using gradle, in "build.gradle" file add the following in the "dependencies"

implementation 'org.springframework.boot:spring-boot-starter-validation'

testImplementation 'org.springframework.boot:spring-boot-starter-test'

If you are using SpringBoot and you are migrating to Spring Boot 3 , you need to replace all your references of javax.validation with jakarta.validation.

Check the release notes of Spring Boot:

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM