我们可以在Springboot optaplanner中使用多个@PlanningSolution类和多个SolverManager吗? [英] can we use multiple @PlanningSolution classes and multiple SolverManager in Springboot optaplanner

查看:388
本文介绍了我们可以在Springboot optaplanner中使用多个@PlanningSolution类和多个SolverManager吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用optaplanner-spring-boot-starter的Springboot应用程序,云平衡问题解决方案可以与一个计划解决方案和SolverManager配合使用,类似于
https://github.com/DuncanDoyle/optaplanner-sbs-cloud-balancing/tree/master/optaplanner-sbs ,但是当定义多个计划解决方案并使用SolverManager调用它时,会引发错误

For Springboot application using optaplanner-spring-boot-starter, the cloudbalancing problem solution works fine with one planning solution and solverManager similar to https://github.com/DuncanDoyle/optaplanner-sbs-cloud-balancing/tree/master/optaplanner-sbs , but when multiple planning solutions are defined and called using a solverManager it throws an error


原因:
org.springframework.beans.factory。 UnsatisfiedDependencyException:
创建在类路径中定义的名称为'solverFactory'的bean时出错
资源
[org / optaplanner / spring / boot / autoconfigure / OptaPlannerAutoConfiguration.class]:
表达了不满意的依赖关系通过方法'solverFactory'
参数0;嵌套的异常是
org.springframework.beans.factory.BeanCreationException:错误
创建在类路径资源
中定义了名称为 solverConfig的bean [org / optaplanner / spring / boot / autoconfigure / OptaPlannerAutoConfiguration .class]:通过工厂方法实例化
Bean失败;嵌套的异常是
org.springframework.beans.BeanInstantiationException:无法实例化
[org.optaplanner.core.config.solver.SolverConfig]:工厂
方法 solverConfig引发了异常;嵌套的异常是
java.lang.IllegalStateException:找到多个类([class
com.test.model.PRCaseAssignment,类
com.test.model.CaseAssignment]),并带有
@PlanningSolution批注。

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'solverFactory' defined in class path resource [org/optaplanner/spring/boot/autoconfigure/OptaPlannerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'solverFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solverConfig' defined in class path resource [org/optaplanner/spring/boot/autoconfigure/OptaPlannerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.optaplanner.core.config.solver.SolverConfig]: Factory method 'solverConfig' threw exception; nested exception is java.lang.IllegalStateException: Multiple classes ([class com.test.model.PRCaseAssignment, class com.test.model.CaseAssignment]) found with a @PlanningSolution annotation.

我们如何定义多个@PlanningSolution类并使用SolverManager进行调用,是否需要注释任何类型的限定符?任何帮助表示赞赏。谢谢。

How can we define multiple @PlanningSolution classes and call using the solverManager, are there any kind of Qualifiers which needs to be annotated? Any help is appreciated. Thanks.

推荐答案

请问具有多个解决方案类的用例是什么?

May I ask what is the use case for having multiple solution classes?

optaplanner-spring-boot-starter 仅支持单个求解器配置,因此仅支持单个解决方案类。 SolverManager API也是如此:您可以向 SolverManager 提交多个计划问题,但是它们必须相同类型(解决方案类)并共享相同的求解器配置。要提交其他类型的计划问题,您必须创建 SolverManager 的新实例。请参阅文档,以了解如何创建以下实例:手动 SolverManager

The optaplanner-spring-boot-starter supports only a single solver configuration and thus only a single solution class. So does the SolverManager API: you can submit multiple planning problems to the SolverManager, but they have to be of the same type (solution class) and share the same solver configuration. To submit a planning problem of a different type, you have to create a new instance of the SolverManager. See the documentation on how to create an instance of the SolverManager manually.

这篇关于我们可以在Springboot optaplanner中使用多个@PlanningSolution类和多个SolverManager吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆