Annotation not applicable to type use with Java 8 in IntelliJ Idea

Answered

I am trying to use "@Email" validation annotation from "org.hibernate.validator.constraints" package, but I am getting a compilation error :- "@Email not applicable to type use" 

 

Usage:- 

List<@Email String> emailIds;

 

Environment:- Java 8, maven , IntelliJ (2016.1)

 

0
6 comments

So, does it build using Maven?

Here is the answer how you can validate a collection (each element inside a collection): http://stackoverflow.com/a/4329039/104891 .

BTW, why do you think that the problem is in IDEA?

0
Avatar
Permanently deleted user

Java 8 has introduced Type annotations, kindly refer to http://stackoverflow.com/a/31796895 

 

0

@Email has the following @Target(value={METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER})

There is no TYPE.

0

Can you build the project without errors outside of IDEA using Maven?

0
Avatar
Permanently deleted user

No. I believe this particular annotation does not support type as yet. Thanks for pointing this.

0

Please sign in to leave a comment.