Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a new annotation?

Tags:

java

spring

How can I create a new annotation based on a Spring @Service annotation or @Component?

I want just to change the name for a more semantic use: for example change the name to @TransactionelService.

like image 265
klagrida Avatar asked Oct 18 '12 11:10

klagrida


1 Answers

You can create your own annotation (e.g. @MyComponent) annotated with the corresponding spring annotation. For example:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface MyComponent {
}
like image 134
dogbane Avatar answered Sep 21 '22 20:09

dogbane