简体   繁体   中英

Using java annotations without CDI

I have been searching for a while, but I could not found any usefull informations about my question. is it possible to use Java annotations without initializing annotation implementation with CDI or EJB?

You can use annotations as much as you like.

Some annotations are used by the compiler, like @Override, for example. Most annotations are available at runtime also, and are heavily used with reflection.

CDI implementations - for example - use reflection to find injection points and injectable types. If you use the typical CDI annotations, but do not have any CDI implementation in your running program, then it just does nothing. That's it. You could - of course - do the reflective analysis yourself.

One additional note about annotations: If the class file of an annotation is not found in the class patth, the annotation on an element will be silently dropped, so that it is not available anymore for reflective access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM