如何为List JAXB创建setter

时间:2017-04-27 16:01:21

标签: java list maven xsd jaxb

我有一些XSD文件,我尝试使用属性java.util.List的setter生成Java Class(Jaxb)。

我有这个pom.xml:

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>src/main/resources/here</schemaDirectory>
                    <generatePackage>ws</generatePackage>
                    <includeSchema>${basedir}/src/main/resources/file.xsd</includeSchema>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.10.0</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>

我已添加,但无法识别此参数:

<arg>-Xcollection-setter-injector</arg>

你知道怎么做吗?

谢谢,

1 个答案:

答案 0 :(得分:1)

我认为您错过了configuration参数extension

<extension>true</extension>

<强>的pom.xml

<configuration>
                    <extension>true</extension>
                    <args>
                        <arg>-Xsimplify</arg>
                        <arg>-Xcollection-setter-injector</arg>
                    </args>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.11.0</version>
                        </plugin>
                    </plugins>
                </configuration>