0

With the following plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
        <clearOutputDir>false</clearOutputDir>
    </configuration>
</plugin>

I generate classes from an XSD schema (let's say entity.xsd) placed in the /src/main/resources, the root element with namespace definition is on the example below:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="https://www.mywebpage.com"
    targetNamespace="https://www.mywebpage.com"
    elementFormDefault="qualified">

    ...
</xs:schema>

Upon mvn clean install, the generated structure in the target/generated-sources/jaxb is very odd:

  • target/generated-sources/jaxb
    • https
      • www_mywebpage
        • ObjectFactory.java
        • Entity.java
        • EntityDetailsRequest.java
        • EntityDetailsResponse.java

I expected something like:

  • target/generated-sources/jaxb
    • com.mywebpage
      • ObjectFactory.java
      • Entity.java
      • EntityDetailsRequest.java
      • EntityDetailsResponse.java

What do I do wrong?

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
  • Why did you expect `com.mywebpage`? You didn't specify that anywhere. Perhaps if you explicitly specified `` you'd get what you want. I mean, that's in the very first [example](http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html) on the plugin documentation site. – Andreas Oct 04 '18 at 20:05
  • @Andreas: I followed the following tutorial: https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/. The plugin should generate the package according to the namespace. – Nikolas Charalambidis Oct 04 '18 at 20:11

1 Answers1

1

I had a mistake in the XSD schema. The maven-jaxb2-plugin doesn't recognise https but only http.

I changed:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="https://www.mywebpage.com"
    targetNamespace="https://www.mywebpage.com"

To:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="http://www.mywebpage.com"
    targetNamespace="http://www.mywebpage.com"

And the generated structure is as I expected and described in my question.

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183