Mykola Kozhemiaka
Mykola Kozhemiaka

Reputation: 31

After adding @XmlRootElement annotation for generated classes i can't access them in my source classes

As i've already described in title i have a problem in accessing generated classes from my source classes when i add @XmlRootElement annotation on resource -generation step.

My jaxb2-maven-plugin config:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>src/main/resources/schemas</schemaDirectory>
                <packageName>my.classses</packageName>
                <bindingDirectory>${project.basedir}/src/main/resources/xjb</bindingDirectory>
                <extension>true</extension>
            </configuration>
        </plugin>

Any help will be useful, thanks in advance!

Upvotes: 0

Views: 337

Answers (1)

Dennis Hunziker
Dennis Hunziker

Reputation: 1293

The generated source files are probably located under generated-sources which is not added as a source directory by default, try using something like:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>${project.build.directory}/generated-sources/DIRNAME</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Just replace DIRNAME with the name of the directory the generated files are in.

Upvotes: 1

Related Questions