0

Does anyone know how to use the javax.validation package in IntelliJ? I'm using Gradle, the package won't auto import like everything else I use. I also tried downloading it from a jar website but that didn't work either.My Gradle project, "cannot resolve symbol" on anything related to javax.validation

Spectric
  • 30,714
  • 6
  • 20
  • 43
Sofie
  • 11
  • 2
  • Can we see the entry you have in gradle for this package? – Omar Abdel Bari Oct 04 '20 at 23:43
  • Could this be related to https://stackoverflow.com/questions/24600804/java-project-with-gradle-in-intellij-idea-cannot-resolve-symbol-google-but-pr ? This applies only if you manually added the dependency. – Omar Abdel Bari Oct 04 '20 at 23:46
  • 1
    @OmarAbdelBari Yes I think this is what you mean? https://imgur.com/a/MN42vYt this is where it is in my Project Structure. – Sofie Oct 04 '20 at 23:48
  • In that photo it appears that you manually referenced the file locally. I think you did mention that you tried both approaches. My experience with Intellij was mainly with the Android development kit and I recall you had to re-build the project if you did some changes to gradle dependencies. Not sure if that appears on vanilla IntelliJ IDEA though. Did you try to see if that exists? Occasionally, rebuild project doesn't work so I would need to clean then build project. – Omar Abdel Bari Oct 04 '20 at 23:55
  • @OmarAbdelBari Yeahh I just tried clean and rebuild and that hasn't fixed it either :( I'm so bad with intelliJ lol my problem is probably something obvious that I missed. But thank u for the help!! – Sofie Oct 05 '20 at 00:03
  • did you try `implementation 'org.springframework.boot:spring-boot-starter-validation'` ? – Marco Oct 05 '20 at 00:06
  • Does the answer here help? https://stackoverflow.com/questions/45035685/cannot-import-javax-validation-constraints-in-intellij-idea – Omar Abdel Bari Oct 05 '20 at 00:07
  • @Marco omg thank you so much!! I thought of this literally hours ago but since I didn't know how to write it out I just started trying other things. Thank you again, ur a life saver :))) – Sofie Oct 05 '20 at 00:26
  • @Marco could you repost that as an answer so I can upvote and mark it as correct? – Sofie Oct 05 '20 at 00:32

1 Answers1

0

In the latest version of spring boot the validation was moved to another spring boot starter lib, you need to import:

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

a this should be work.

Marco
  • 517
  • 3
  • 10