Using package-info.java for JAXB

2.8k Views Asked by At

I am unable to build my application because of the syntax in the package-info.java file. The sample below is just a demo but any sample I try gives me the syntax errors I would expect since I'm placing code before the package and imports. How exactly are you suppose to get this to work if the syntax below is what is actually suppose to go into package-info.java?

Update: Another way to ask this question is, shouldn't the annotation go at the bottom? My compiler, IntelliJ, certainly things so...

@XmlSchema(
    elementFormDefault=XmlNsForm.QUALIFIED,
    namespace="http://www.example.com/FOO",
    xmlns={@XmlNs(prefix="bar",
                  namespaceURI="http://www.example.com/BAR")}
)
package blog.prefix;

import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
2

There are 2 best solutions below

0
On

The problem was my IDE. For this to work in IntelliJ you must disable "Optimize Imports".

0
On

It's working fine in IntellIJ 2018 version :)