java cxf-codegen-plugin 不生成源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10164522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 23:53:11  来源:igfitidea点击:

cxf-codegen-plugin doesn't generate sources

javamavencxfwsdl2java

提问by Vespasian

I'm trying to get the cxf-codegen-pluginto generate sources from my wsdl file. When calling wsdl2java manual the desired classes are generated but when using mvn generate-sourcesnothing happens and I get the message "No goals needed for project". Calling the plugin directly doesn't helps.

我试图让cxf-codegen-plugin从我的 wsdl 文件生成源代码。当调用 wsdl2java 手册时,会生成所需的类,但是当使用mvn generate-sources 时什么也没有发生,我收到消息“项目不需要目标”。直接调用插件没有帮助。

The extract from my poms follows:

我的poms摘录如下:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/MyServiceInterface.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

回答by Donal Fellows

That looks very much like the way I (successfully) configure that plugin in one of my projects; I would expect that to work. (I believe you can omit the <sourceRoot>; the default setting for that is the one you've stated.)

这看起来非常像我(成功)在我的一个项目中配置该插件的方式;我希望这能奏效。(我相信您可以省略<sourceRoot>; 默认设置就是您所说的那个。)

The only thing I can think of would be if you had put that plugin configuration in either a non-active Maven profile or (more likely) in the <pluginManagement>section instead of the straight <plugins>section; the pluginManagement section overrides aspects of the configuration of plugins, but doesn't actually enable them for use. (It does however affect explicit usage; I know you don't want to do that.)

我唯一能想到的是,如果您将该插件配置放在非活动的 Maven 配置文件中,或者(更有可能)放在该<pluginManagement>部分而不是直接<plugins>部分;pluginManagement 部分覆盖了插件配置的各个方面,但实际上并未启用它们以供使用。(但是它确实会影响显式使用;我知道您不想这样做。)

回答by Ramon Michael

In my case at least, I thought it wasn't generating source code as well, but it actually was. The issue was that the folder target/generated/cxf was designated by Eclipse as a source folder, which I didn't do manually. So the source was toward the top of my project, in package structure, not in the folder structure below, which is where I was looking and expecting it to be.

至少就我而言,我认为它也不会生成源代码,但实际上确实如此。问题是文件夹 target/generated/cxf 被 Eclipse 指定为源文件夹,我没有手动执行。所以源代码在我项目的顶部,在包结构中,而不是在下面的文件夹结构中,这是我正在寻找和期望的位置。

回答by hipokito

In my case as long as I had the old target directory (defined in <sourceRoot>/path/to/target</sourceRoot>) nothing was being generated. Only after deleting the target folder manually plugin actually started to generate the sources.

就我而言,只要我有旧的目标目录(在 中定义<sourceRoot>/path/to/target</sourceRoot>),就不会生成任何内容。只有在手动删除目标文件夹后,插件才真正开始生成源。