我在opta planner文档中尝试了一个简单的例子
这是我的配置
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<!-- Domain model configuration -->
<scanAnnotatedClasses />
<!-- Score configuration -->
<scoreDirectorFactory>
<scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
<easyScoreCalculatorClass>
optaplanner.learn.CloudBalancingEasyScoreCalculator
</easyScoreCalculatorClass>
</scoreDirectorFactory>
<!-- Optimization algorithms configuration -->
<termination>
<secondsSpentLimit>30</secondsSpentLimit>
</termination>
</solver>
当我运行应用程序时,我得到以下错误
Exception in thread "main" java.lang.IllegalArgumentException: Unmarshalling of solverConfigResource (solver-config.xml) fails.
at org.optaplanner.core.impl.solver.XStreamXmlSolverFactory.configure(XStreamXmlSolverFactory.java:114)
at org.optaplanner.core.api.solver.SolverFactory.createFromXmlResource(SolverFactory.java:108)
at optaplanner.learn.App.main(App.java:15)
Caused by: com.thoughtworks.xstream.converters.ConversionException: Cannot load java class
optaplanner.learn.CloudBalancingEasyScoreCalculator
---- Debugging information ----
message : Cannot load java class
optaplanner.learn.CloudBalancingEasyScoreCalculator
class : java.lang.Class
required-type : java.lang.Class
converter-type : com.thoughtworks.xstream.converters.SingleValueConverterWrapper
wrapped-converter : com.thoughtworks.xstream.converters.extended.JavaClassConverter
line number : 11
class[1] : org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.optaplanner.core.config.solver.SolverConfig
有人遇到过这个问题吗?
Optaplanner
无法加载easyscorecalculatorclass
。是否需要运行示例应用程序的任何其他设置?
答案 0 :(得分:1)
当我将xml标签包装到一行时,它可以工作
<easyScoreCalculatorClass>optaplanner.learn.CloudBalancingEasyScoreCalculator</easyScoreCalculatorClass>