Как создать классы POJO с помощью плагина JAXB maven в java 11

При необходимости создать классы Pojo с помощью плагина JAXB maven в java 11, я использую этот плагин в java 8 и отлично работаю:

<plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>             
            <executions>
                <execution>
                    <id>process-xsd1</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <schemaIncludes>
                            <include>*.xsd</include>
                        </schemaIncludes>
                        <generateDirectory>generated-sources</generateDirectory>
                        <generatePackage>com.bill.entities</generatePackage>
                        <extension>true</extension>
                        <args>
                            <arg>-Xannotate</arg>
                            <arg>-npa</arg>
                        </args>
                        <plugins>
                            <plugin>
                                <groupId>org.jvnet.jaxb2_commons</groupId>
                                <artifactId>jaxb2-basics-annotate</artifactId>
                                <version>0.6.3</version>
                            </plugin>
                            <plugin>
                                <groupId>org.jvnet.jaxb2_commons</groupId>
                                <artifactId>jaxb2-basics</artifactId>
                                <version>0.6.3</version>
                            </plugin>
                            <plugin>
                                <groupId>org.jboss.resteasy</groupId>
                                <artifactId>resteasy-jettison-provider</artifactId>
                                <version>2.2.0.GA</version>
                            </plugin>
                            <plugin>
                                <groupId>com.fasterxml.jackson.core</groupId>
                                <artifactId>jackson-annotations</artifactId>
                                <version>2.1.1</version>
                            </plugin>
                        </plugins>
                    </configuration>
                </execution>
                <execution>
                    <id>process-xsd2</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <forceRegenerate>true</forceRegenerate>
                        <schemaDirectory>src/main/resources/FDP/acquire/v1</schemaDirectory>
                        <bindingDirectory>src/main/resources/FDP</bindingDirectory>
                        <generateDirectory>generated-sources</generateDirectory>                            
                        <strict>false</strict>
                        <extension>true</extension>
                        <args>
                            <arg>-no-header</arg>
                            <arg>-Xxew</arg>
                            <arg>-Xxew:instantiate lazy</arg>
                            <arg>-Xxew:delete</arg>
                        </args>
                        <plugins>
                            <plugin>
                                <groupId>com.github.jaxb-xew-plugin</groupId>
                                <artifactId>jaxb-xew-plugin</artifactId>
                                <version>1.0</version>
                            </plugin>
                        </plugins>
                    </configuration>
                </execution>                    
            </executions>
        </plugin>

и вот моя схема *.xsd:


    <?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema targetNamespace = "http://www.bill.com/NextStam"
    elementFormDefault = "qualified" xmlns:xs = "http://www.w3.org/2001/XMLSchema"
    xmlns:tns = "http://www.bill.com/NextStam" xmlns:jaxb = "http://java.sun.com/xml/ns/jaxb"
    jaxb:version = "2.1" xmlns:annox = "http://annox.dev.java.net"
    jaxb:extensionBindingPrefixes = "annox" xmlns:jl = "http://annox.dev.java.net/java.lang"
    xmlns:jns = "http://annox.dev.java.net/com.fasterxml.jackson.annotation">

    <xs:include schemaLocation = ""></xs:include>
    <xs:complexType name = "FIProfile">
        <xs:sequence>
            <xs:element name = "allowedConnections" type = "xs:int"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "AllowedConnections" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "activeConnections" type = "xs:int"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "ActiveConnections" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsCustomer" type = "xs:boolean"
                nillable = "true" default = "false">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsCustomer" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsAccounts" type = "xs:boolean"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsAccounts" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsTransactions" type = "xs:boolean"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsTransactions" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsStatements" type = "xs:boolean"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsStatements" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsImage" type = "xs:boolean"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsImage" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name = "supportsTransfer" type = "xs:boolean"
                nillable = "true">
                <xs:annotation>
                    <xs:appinfo>
                        <annox:annotate target = "field">
                            <jns:JsonProperty value = "SupportsTransfer" />
                        </annox:annotate>
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

вы даже не указали какие ошибки вы получаете

SMA 07.04.2022 11:42
Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
В компьютерном программировании биты играют важнейшую роль в представлении и манипулировании данными на двоичном уровне. Побитовые операции...
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Приходилось ли вам сталкиваться с требованиями, в которых вас могли попросить поднять тревогу или выдать ошибку, когда метод Java занимает больше...
Полный курс Java для разработчиков веб-сайтов и приложений
Полный курс Java для разработчиков веб-сайтов и приложений
Получите сертификат Java Web и Application Developer, используя наш курс.
1
1
22
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Пример использования ниже:

Пожалуйста, обратите внимание на внутреннюю зависимость плагина.

              <plugin>
               <groupId>org.jvnet.jaxb2.maven2</groupId>
               <artifactId>maven-jaxb2-plugin</artifactId>
               <version>${maven-jaxb2-plugin.version}</version>
               <executions>
                   <execution>
                       <id>example-xmls</id>
                       <goals>
                           <goal>generate</goal>
                       </goals>
                       <configuration>
                           <generateDirectory>target/generated-sources/xjc/</generateDirectory>
                           <schemaDirectory>${basedir}/src/main/resources/schemas/xsd</schemaDirectory>
                           <schemaIncludes>
                               <include>**/*.xsd</include>
                           </schemaIncludes>
                           <bindingDirectory>${basedir}/src/main/resources/schemas/xjb</bindingDirectory>
                           <bindingIncludes>
                               <include>**/*.xjb</include>
                           </bindingIncludes>
                       </configuration>
                   </execution>
               </executions>
               <dependencies>
                   <dependency>
                       <groupId>org.glassfish.jaxb</groupId>
                       <artifactId>jaxb-runtime</artifactId>
                       <version>2.3.3</version>
                   </dependency>
               </dependencies>
           </plugin>

Ссылка: https://jcompetence.com/2022/03/07/jdk-17-and-maven-jaxb2-plugin/

Другие вопросы по теме