简体   繁体   English

Maven Jaxb插件无法从目标文件夹生成类

[英]Maven Jaxb plugin can't generate classes from target folder

I try to copy an xsd file from a maven dependency and put it into target folder with others xsd files of my project and after that i wante to generate the jaxb classes but it can't generate them in the same time. 我尝试从Maven依赖项复制一个xsd文件,并将其与我项目的其他xsd文件放到目标文件夹中,此后,我想生成jaxb类,但无法同时生成它们。 When i make only the code of xsd file of the dependency, it can generate the jaxb classes but for the xsd files of my project it can't. 当我仅制作依赖项的xsd文件的代码时,它可以生成jaxb类,但是对于我项目的xsd文件则不能。

    <plugin>
     <!-- copy the xsdl files of my current project into the target folder-->
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-resources-xsd</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/tmp/schemas</outputDirectory>
                        <encoding>UTF-8</encoding>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/main/schemas</directory>
                                <includes>
                                    <include>**/*.xsd</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
   <!--copy the xsd files of the dependency into the target folder of my current project-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-libraries</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.my.dependency</groupId>
                                <artifactId>res-communes</artifactId>
                                <version>${res-communes.version}</version>
                                <type>xsd</type>
                                <classifier>typesFy</classifier>
                                <destFileName>typesFy.xsd</destFileName>
                                <outputDirectory>${project.build.directory}/tmp/schemas</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>true</overWriteSnapshots>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${maven-jaxb2-plugin.version}</version>
            <dependencies>
                <dependency>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                    <version>${jackson.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <extension>true</extension>
                <enableIntrospection>true</enableIntrospection>
                <markGenerated>true</markGenerated>
                <schemas>
                    <schema>
                        <fileset>
                            <directory>${project.build.directory}/tmp/schemas</directory>
                        </fileset>
                    </schema>
                </schemas>
                <args>
                    <arg>-Xts:style:org.apache.commons.lang.builder.ToStringStyle.MULTI_LINE_STYLE</arg>
                    <arg>-Xbg</arg>
                    <arg>-Xfluent-api</arg>
                    <arg>-Xinheritance</arg>
                    <arg>-Xannotate</arg>
                    <arg>-XJsr303Annotations</arg>
                </args>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>${jaxb2-basics.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics-annotate</artifactId>
                        <version>${jaxb2-basics-annotate.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-ts</artifactId>
                        <version>${cxf-xjc-ts.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-boolean</artifactId>
                        <version>${cxf-xjc-boolean.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-fluent-api</artifactId>
                        <version>${jaxb2-fluent-api.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>com.github.krasa</groupId>
                        <artifactId>krasa-jaxb-tools</artifactId>
                        <version>${krasa-jaxb-tools.version}</version>
                    </plugin>
                </plugins>
            </configuration>
        </plugin>

maven-jaxb2-plugin runs in generate-sources phase by default. 默认情况下, maven-jaxb2-plugingenerate-sources阶段运行。 You unpack your schemas in generate-resources . 您可以在generate-resources解压缩模式。 Schemas are just not yet there when you try to compile them. 当您尝试编译架构时,它们还不存在。

To debug such problems run mvn -X clean install and check the logs. 要调试此类问题,请运行mvn -X clean install并检查日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM