You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何排除ai.timefold.solver.quarkus模块解决多@PlanningSolution注解错误?

解决Timefold Quarkus构建错误:多个@PlanningSolution类冲突

错误详情

构建时抛出以下异常:

java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step ai.timefold.solver.quarkus.deployment.TimefoldProcessor#recordAndRegisterBeans threw an exception: java.lang.IllegalStateException: Multiple classes ([Model1.domain.Solution1Table, Model2.domain.Solution2Table]) found with a @PlanningSolution annotation.

之前方法无效的原因

你尝试的几种方式都无法正确排除timefold-solver-quarkus模块,原因如下:

  • quarkus.arc.exclude-types:仅用于排除CDI Bean,无法移除依赖模块本身。
  • maven-compiler-plugin/maven-jar-plugin的exclude配置:仅作用于当前项目的源代码/打包产物,不影响依赖库中的类。
  • BOM中的exclusion:BOM仅负责版本管理,不会引入实际依赖,因此排除BOM中的条目对依赖引入无影响。

正确的模块排除方法

要移除timefold-solver-quarkus模块,需在实际引入该模块的依赖项中添加排除规则:

  1. 找到项目中引入Timefold Quarkus相关的依赖(例如timefold-solver-quarkus-extension),在其中添加exclusion:
<dependency>
    <groupId>ai.timefold.solver</groupId>
    <artifactId>timefold-solver-quarkus-extension</artifactId>
    <version>${version.ai.timefold.solver}</version>
    <exclusions>
        <exclusion>
            <groupId>ai.timefold.solver</groupId>
            <artifactId>timefold-solver-quarkus</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  1. 如果无法确定哪个依赖引入了timefold-solver-quarkus,可以运行以下Maven命令查看依赖树:
mvn dependency:tree -Dincludes=ai.timefold.solver:timefold-solver-quarkus

根据输出找到对应的父依赖,再添加排除规则。

替代方案:指定目标Solution类

如果不需要完全排除Quarkus集成模块,仅需解决多个@PlanningSolution类的冲突,可以通过配置指定Timefold要使用的Solution类:

在application.properties中添加以下配置之一:

  • 指定Solution类所在包:
quarkus.timefold.solution-package=Model1.domain
  • 指定具体的Solution类:
quarkus.timefold.solution-class=Model1.domain.Solution1Table

这样Timefold处理器只会处理指定的Solution类,不会触发多类冲突的错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 04:25:41