简体   繁体   English

使用没有CDI的java注释

[英]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? 是否可以使用Java注释而无需使用CDI或EJB初始化注释实现?

You can use annotations as much as you like. 您可以根据需要使用注释。

Some annotations are used by the compiler, like @Override, for example. 编译器使用某些注释,例如@Override。 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. CDI实现 - 例如 - 使用反射来查找注入点和注入类型。 If you use the typical CDI annotations, but do not have any CDI implementation in your running program, then it just does nothing. 如果您使用典型的CDI注释,但在正在运行的程序中没有任何CDI实现,那么它什么都不做。 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. 关于注释的另一个注意事项:如果在类patth中找不到注释的类文件,则元素上的注释将被静默删除,因此它不再可用于反射访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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