Quarkus升级至3.6.x后因CXF代码生成与自定义ConfigSource构建失败求助
Quarkus 3.6.x+升级:CXF代码生成与自定义ConfigSource冲突问题
问题背景
现有项目从Quarkus 3.2.12逐步升级至3.21.x及更高版本,成功升级到3.5.3后,从3.6.x版本开始构建失败,排查发现CXF代码生成逻辑与自定义ConfigSource无法共存于同一项目。
编译错误日志
... [WARNING] [io.quarkus.deployment.CodeGenerator] The following services are not (yet) available and will be disabled during configuration initialization at the current build phase: com.example.config.MyConfigSource ... ... [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.6.9:generate-code-tests (default) on project MyProject: Quarkus code generation phase has failed: InvocationTargetException: org.eclipse.microprofile.config.spi.ConfigSource: Provider com.example.config.MyConfigSource could not be instantiated: ... ... -> [Help 1]
自定义ConfigSource代码
public class MyConfigSource implements ConfigSource { // Snip --8<-- protected final Config config; // Snip --8<-- public MyConfigSource() { this.config = ConfigProviderResolver.instance() .getBuilder() .addDefaultSources() .build(); } // Snip --8<-- }
(如需MyConfigSource类更多细节可提供)
pom.xml关键配置片段
<dependency> <groupId>io.quarkiverse.cxf</groupId> <artifactId>quarkus-cxf</artifactId> </dependency> <!-- Snip --> <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.platform.version}</version> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> <goal>generate-code-tests</goal> </goals> </execution> </executions> </plugin> <!-- Snip --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>${jaxb2-maven-plugin-version}</version> <executions> <execution> <id>generate-bleh-sources</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <clearOutputDir>true</clearOutputDir> <enableIntrospection>true</enableIntrospection> <noGeneratedHeaderComments>true</noGeneratedHeaderComments> <noPackageLevelAnnotations>true</noPackageLevelAnnotations> <outputDirectory>${project.basedir}/target/generated-sources/bleh</outputDirectory> <readOnly>true</readOnly> <sources> <source>${project.basedir}/src/main/resources/bleh.xsd/BLEH_Common.xsd</source> </sources> </configuration> </plugin> <!-- Snip --> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>4.0.4</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <wsdlRoot>${basedir}/src/main/resources/wsdl/blah</wsdlRoot> <includes> <include>blah1.wsdl</include> <include>blah2.wsdl</include> </includes> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin>
(如需pom.xml更多细节可提供)
已尝试的解决措施
- 将WSDL文件及代码生成逻辑迁移至单独项目生成Jar包,替代原项目中的
<goal>generate-code</goal>步骤,该方法可行,但测试类构建仍存在问题。 - 尝试使用自定义ConfigSourceFactory替代ConfigSource,但仍出现相同问题。
- 考虑将自定义ConfigSource类迁移至单独项目/Jar包,但工作量较大。
请求解决建议
恳请针对上述问题提供可行的解决建议,避免大量重构工作的同时解决构建冲突。
内容的提问来源于stack exchange,提问作者TungstenX
相关产品推荐
相关产品推荐

