Harold L. Brown Harold L. Brown - 1 month ago 12
Java Question

IntelliJ doesn't recognize import statements for JAXB classes

I'm using IntelliJ IDEA 14 as IDE and jaxb2-maven-plugin for creating Java classes from XSD files.

When compiling my module with Maven no errors are displayed. Even when using the command

make
or
compile
in IntelliJ no errors are displayed in the status popup.

But in the files itself and in the project browser compile errors are constantly displayed. It seems like IntelliJ doesn't recognize the import statements of my classes in the target folder.

The error statements look like this (bold means coloured in red):

com.my.package.generated.MyClass

The
generated
package seems to be invisible for the IDE. How can I fix this?

Answer

After using this workaround and recreating my project it worked again.

Quote:

If you use maven-jaxb2-plugin with multiple schema for example

        <configuration>
            <bindingDirectory>src/main/xjb/</bindingDirectory>
            <schemaDirectory>src/main/resources/</schemaDirectory>
        </configuration>

with multiple xsd/xjb in it. One with:

    <jaxb:schemaBindings>
        <jaxb:package name="com.test.a"/>
    </jaxb:schemaBindings>

Another with:

    <jaxb:schemaBindings>
        <jaxb:package name="com.test.b"/>
    </jaxb:schemaBindings>