jaxb2-maven-plugin to report problems on Console

175 Views Asked by At

I have a maven-based build script that runs jaxb2-maven-plugin (schemagen) to generate XSD from Java classes. I have done something wrong and it won't generate it.

The project is very complex and it is difficult to re-create in console the exact command line.

In my .pom file I just have

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <id>schemagen</id>
                    <goals>
                        <goal>schemagen</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </configuration>
        </plugin>

What options I may use to command schemagen / plugin to show what was the cause of error on console?

1

There are 1 best solutions below

0
On

Answer to your question

  1. I didn't find anything wrong in your POM.xml file, as I used the same POM file and it is generating the required schema at my target directory.
  2. Please find the Domain Object user and I have generated XSD schema.

                    /**
                 * 
                 */
                package com.example;
    
                /**
                 * @author Praveen
                 *
                 */
                public class User {
    
                    private String ename;
                    private String designation;
                    public String getEname() {
                        return ename;
                    }
                    public void setEname(String ename) {
                        this.ename = ename;
                    }
                    public String getDesignation() {
                        return designation;
                    }
                    public void setDesignation(String designation) {
                        this.designation = designation;
                    }
    
                }
    
  3. POM file

                            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                          <modelVersion>4.0.0</modelVersion>
                          <groupId>org.app</groupId>
                          <artifactId>sample</artifactId>
                          <version>0.0.1-SNAPSHOT</version>
                          <build>
                          <plugins>
                          <plugin>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>jaxb2-maven-plugin</artifactId>
                                    <version>1.6</version>
                                    <executions>
                                        <execution>
                                            <id>schemagen</id>
                                            <goals>
                                                <goal>schemagen</goal>
                                            </goals>
                                        </execution>
                                    </executions>
                                    <configuration>
                                        <includes>
                                            <include>**/*.java</include>
                                        </includes>
                                    </configuration>
                                </plugin>
                          </plugins>
    
                          </build>
    
    
    
                        </project>
    
  4. Maven Goals as

    clean install -e

  5. Output on my IDE, please refer below figure.

schema generation

schem gen

  1. Please refer these example from this link