Adding annotations manually
You can add annotations in your source code by directly adding the annotation in the Java™ editor.
Procedure
- In the Enterprise Explorer view, double-click your Java class to open the file in the Java editor.
- Place your cursor in the section of your class (class level, method level) where you want to add an annotation.
-
Type the symbol
@followed by the name of your annotation:@Session @InterceptorsNote: The order in which you place the annotations is not significant, though generally, the component-defining annotation appears before other types of annotations. What is important is that annotations are placed in the appropriate place in the source file; class-level annotations must appear before the class declaration; method-level annotations are introduced before the method declaration, and field-level annotations are applied to the field itself. -
If the annotation requires parameters, an error appears
in the margin. You can right-click the error and select Quick Fix
(
) to import required jars or to add required
parameters.