Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotations "not applicable to type"

Tags:

java

I am quite new to IntelliJ being a Eclipse user for many years, so I really find this error where all annotations expect for the @Override are showing error "not applicable to type"

E.g the @PostConstruct annotation from JBoss Errai is showing this errors all around, where the import is there with no error at all.

How do I fix this?

Update:

E.g

@PostConstruct // When hovered with the mouse pointer '@PostContruct' is not applicable to method
public void init() {
}

Screenshot: http://snag.gy/q5cW5.jpg

like image 331
quarks Avatar asked Aug 07 '13 12:08

quarks


1 Answers

Looking at the definition, one sees @Target mentioning method. So you might have imported a totally different PostConstruct annotation. Inspect the imports / go to the definition in IntelliJ.

package javax.annotation;

@Documented
@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface PostConstruct
like image 66
Joop Eggen Avatar answered Sep 18 '22 00:09

Joop Eggen