我使用eclipse進行optaplanner項目開發,並且能夠從eclipse執行我的代碼而沒有任何問題。爲了使這個項目成爲可執行文件,我使用eclipse導出嚮導將其導出爲jar文件。Optaplanner - 運行可執行jar時出錯,但在eclipse中正常工作
然後我從運行使用命令java -jar myOptaPlanner.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)
這真的是一個錯誤還是我出口是錯誤的?
更新:我試圖導出使用maven-shade-plugin
罐子,這裏也出現同樣的錯誤。
感謝
在封面之下,OptaPlanner使用org.reflections掃描類路徑。我用罐子測試了這個沒有任何問題。你在使用OSGi,Jigsaw,JBoss模塊還是其他特殊的類加載環境? –