You need to enable JavaScript to run this app. pom.xml配置Apache CXF Codegen插件,更新Maven时execution标签报错如何解决
优惠活动
大模型
产品
解决方案
定价
更多

pom.xml配置Apache CXF Codegen插件,更新Maven时execution标签报错如何解决

Apache CXF Codegen插件execution标签报错修正方案

核心报错触发原因

  • 配置位置错位:如果将带<execution>的执行配置全部移入<pluginManagement>节点但没有在实际生效的<build><plugins>节点引用该插件,Maven校验会识别不到执行逻辑的挂载点,直接报<execution>标签无效
  • 版本兼容性问题:cxf-codegen-plugin 3.3.0和当前使用的JDK、Spring Boot版本不匹配时,插件本身的参数校验规则无法正常加载,会误报标签语法错误
  • 源码路径未关联:IDE未将插件生成的源码目录标记为有效源码路径,会连带报配置标签无效

对应修正步骤

  • 拆分插件配置结构
    正确的结构为:在<pluginManagement>节点仅维护插件版本号,将带执行逻辑的<execution>配置放到项目实际生效的<build><plugins>节点下,参考配置:
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- Spring Boot插件配置 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- CXF Codegen实际生效配置 -->
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/CustomerOrders.wsdl</wsdl>
                                    <wsdlLocation>classpath:CustomerOrders.wsdl</wsdlLocation>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
  • 调整插件版本匹配体系
    根据当前JDK版本、Spring Boot版本选择兼容的cxf-codegen-plugin版本:Spring Boot 2.x 系列优先匹配3.4.x版本的插件,避免3.3.0版本在高JDK环境下的校验异常
  • 关联生成源码目录
    手动执行mvn generate-sources命令完成一次代码生成,确认生成文件存在后,在IDE中将${project.build.directory}/generated/cxf目录标记为生成源码根目录,再重新触发Maven项目更新,消除IDE的误报

内容的提问来源于stack exchange,提问作者Sayantan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.08 06:45:04