What is JAXB generated package-info.java

2020-02-17 09:16发布

I'm trying to find some information on what the package-info.java file generated by the JAXB xjc commandline app actually does. All that is in the file is

@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package the.generated.package.path;

What is this package-info.java file used for?

标签: java jaxb xjc
3条回答
再贱就再见
2楼-- · 2020-02-17 09:59

package-info.java is a way to apply java annotations at the package level. In this case Jaxb is using package-level annotations to indicate the namespace, and to specify namespace qualification for attributes (source).

查看更多
孤傲高冷的网名
3楼-- · 2020-02-17 10:04

If you want to define default namespace for elements in your java model, you can define it in package-info.java

查看更多
▲ chillily
4楼-- · 2020-02-17 10:05

This is also useful when you generate javadoc

package-info.java - Can contain a package declaration, package annotations, package comments and Javadoc tags. This file is new in JDK 5.0, and is preferred over package.html.

source : http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#sourcefiles

查看更多
登录 后发表回答