Java Optaplanner-运行可执行jar时出错,但在eclipse中可以正常工作

Java Optaplanner-运行可执行jar时出错,但在eclipse中可以正常工作,java,drools,executable-jar,optaplanner,reflections,Java,Drools,Executable Jar,Optaplanner,Reflections,我使用eclipse进行optaplanner项目开发,并且我能够毫无问题地从eclipse执行代码。为了使该项目成为可执行文件,我使用eclipse导出向导将其导出为jar文件 然后,我使用命令java-jarmyoptaplanner.jar从终端运行jar,然后,我得到下面的错误 WARN given scan urls are empty. set urls in the configuration Exception in thread "main" java.lang.Illega

我使用eclipse进行optaplanner项目开发,并且我能够毫无问题地从eclipse执行代码。为了使该项目成为可执行文件,我使用eclipse导出向导将其导出为jar文件

然后,我使用命令
java-jarmyoptaplanner.jar
从终端运行jar,然后,我得到下面的错误

WARN  given scan urls are empty. set urls in the configuration
Exception in thread "main" java.lang.IllegalStateException: The scanAnnotatedClasses 
(ScanAnnotatedClassesConfig()) did not find any classes with a PlanningSolution 
annotation.
Maybe you forgot to annotate a class with a PlanningSolution annotation.
Maybe you're using special classloading mechanisms (OSGi, ...) and this is a bug. 
If you can confirm that, report it to our issue tracker and workaround it by 
defining the classes explicitly in the solver configuration.
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.loadSolutionClass(ScanAnnotatedClassesConfig.java:106)
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.buildSolutionDescriptor(ScanAnnotatedClassesConfig.java:86)
at org.optaplanner.core.config.solver.SolverConfig.buildSolutionDescriptor(SolverConfig.java:270)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:216)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:57)
at org.roster.app.WorkerRosteringApp.main(WorkerRosteringApp.java:36)
这真的是一个bug还是我导出的错误

更新:我尝试使用
maven shade plugin
导出jar,这里也出现了同样的错误


谢谢,ScanAnnotatedClass在jar文件中似乎不起作用。相反,请使用以下解决方法:

<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
<scanAnnotatedClasses>
    <packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>
path.to.your.SolutionClass
path.to.your.EntityClassI
path.to.your.EntityClassII

并删除配置文件中的
ScanAnnotatedClass

ScanAnnotatedClass在jar文件中似乎不起作用。相反,请使用以下解决方法:

<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
<scanAnnotatedClasses>
    <packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>
path.to.your.SolutionClass
path.to.your.EntityClassI
path.to.your.EntityClassII

并删除配置文件中的
ScanAnnotatedClass

如果不想手动声明解决方案和实体类,包括包含解决方案和实体类的包,也可以作为解决方案:

<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
<scanAnnotatedClasses>
    <packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>

你的包裹在这里

如果您不想手动声明解决方案和实体类,可以找到有关
的文档,包括包含解决方案和实体类的包也可以作为解决方法:

<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
<scanAnnotatedClasses>
    <packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>

你的包裹在这里

有关
的文档可以找到

非常感谢您的帮助。。。它现在正在工作。你认为我必须将此作为一个bug发布给他们吗?是的,这是一个bug,请提供一个干净的复制器更好,找出问题是什么,如果你想贡献的话。在我的一个带有OptaPlanner 7.48.0的tomcat上有类似的问题,它“解决”了这个问题非常感谢你的帮助。。。它现在正在工作。你认为我必须把它作为一个bug发布给他们吗?是的,这是一个bug,请提供一个干净的复制器更好的是,弄清楚问题是什么,如果你想贡献的话。在我的一个tomcat和OptaPlanner 7.48.0上有类似的问题,它“解决”了这个问题。在封面下,OptaPlanner使用org.reflections扫描类路径。我已经用罐子测试过了,没有任何问题。您是否使用OSGi、Jigsaw、JBoss模块或任何其他特殊类加载环境?在封面下,OptaPlanner使用org.reflections扫描类路径。我已经用罐子测试过了,没有任何问题。您是否使用OSGi、Jigsaw、JBoss模块或任何其他特殊的类加载环境?