包注释有什么意义? [英] What's the point of package annotations?

查看:37
本文介绍了包注释有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解类注释的目的,感谢 How 和 whereJava 中使用了注解吗?.包注释的目的是什么,如本博文中所述§7.4.1的 Java 语言规范?

I understand the purpose of class annotations, thanks to How and where are Annotations used in Java?. What is the purpose of package annotations, as described in this blog post and §7.4.1 of the Java Language Specification?

为什么要将元数据与包相关联?你可以做什么类型的事情?

Why would you want to associate metadata with a package? What kinds of things could you do?

推荐答案

  1. bnd 工具(和 maven-bundle-plugin) 使用包注释.将 @Version 和 @Export 注释放在 package-info.java 中允许它生成 OSGi 元数据.
  2. javadoc 使用包注释.
  3. JAXB 使用包级注释,用于示例,指定 Java 类型到 XML Schema 类型包范围的映射.JBoss 的 xml 绑定中也使用了包注释.
  4. Struts 2 约定插件使用 注解,用于为包中的所有操作指定默认拦截器.
  5. 有一些包级别的休眠注释.可以在此处找到这些注释的使用示例.
  1. bnd tool (and maven-bundle-plugin) makes use of package annotations. Putting @Version and @Export annotation in package-info.java allows it to generate OSGi metadata.
  2. javadoc uses package annotations.
  3. JAXB uses package-level annotations, for example, to specify mapping of a Java type to XML Schema type package-wide. Package annotations are also used in JBoss's xml binding.
  4. Struts 2 Convention plugin uses an annotation to specify a default interceptor for all actions in a package.
  5. There are some package-level Hibernate Annotations. An example of those annotations' usage can be found here.

这篇关于包注释有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆