What's the point of package annotations?

前端 未结 6 2095
慢半拍i
慢半拍i 2020-12-08 13:35

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 p

6条回答
  •  遥遥无期
    2020-12-08 13:41

    JAXB for example allows most annotations that are normally used on a type to be equally well applied to a package. The meaning in that case would be to specify the default for all classes in that package.

    For example, if you want all properties of all classes in a package that are exposed via getter/setters to be mapped in XML you could specify @XmlAccessorType(XMLAccessType.PROPERTY) on each class or simply specify it on the package.

提交回复
热议问题