简体   繁体   English

Optaplanner-BenchmarkConfigResource在classLoader中不作为类路径资源存在

[英]Optaplanner - The benchmarkConfigResource does not exist as a classpath resource in the classLoader

I'm new to OptaPlanner and I'm focusing on benchmarking . 我是OptaPlanner的新手 ,我专注于基准测试 I started playing around with the benchmark in Eclipse . 我开始尝试使用Eclipse中的基准测试。 I followed the documentation ( http://docs.jboss.org/optaplanner/release/6.4.0.Final/optaplanner-docs/html_single/index.html#buildAndRunAPlannerBenchmark ), but when trying to run, I got this error : 我遵循了文档( http://docs.jboss.org/optaplanner/release/6.4.0.Final/optaplanner-docs/html_single/index.html#buildAndRunAPlannerBenchmark ),但是在尝试运行时,出现此错误

Exception in thread "main" java.lang.IllegalArgumentException: The benchmarkConfigResource (prova/src/prova/nurseRosteringBenchmarkConfig.xml) does not exist as a classpath resource in the classLoader (sun.misc.Launcher$AppClassLoader@73d16e93).
    at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.configure(XStreamXmlPlannerBenchmarkFactory.java:100)
    at org.optaplanner.benchmark.api.PlannerBenchmarkFactory.createFromXmlResource(PlannerBenchmarkFactory.java:45)
    at prova.ClasseJava.main(ClasseJava.java:10)

Maybe I'm doing something wrong in Java (I need to review it), so here is my code : 也许我在Java中做错了(我需要复习一下),所以这是我的代码

package prova;

import org.optaplanner.benchmark.api.PlannerBenchmark;
import org.optaplanner.benchmark.api.PlannerBenchmarkFactory;

public class ClasseJava {
    public static void main(String[] args) {
        System.out.println("Ok - Before");
        PlannerBenchmarkFactory plannerBenchmarkFactory = PlannerBenchmarkFactory.createFromXmlResource(
                "prova/src/prova/nurseRosteringBenchmarkConfig.xml");
        System.out.println("Ok - After");
        PlannerBenchmark plannerBenchmark = plannerBenchmarkFactory.buildPlannerBenchmark();
        plannerBenchmark.benchmark();
    }   
}

Info : I've placed the file nurseRosteringBenchmarkConfig.xml in the same ClasseJava 's package ( prova ). 信息 :我已经将文件NurseRosteringBenchmarkConfig.xml放在相同的ClasseJava包( prova )中。

Thank you for a little help. 谢谢您的帮助。

Classpath resources are like package names and full classnames. 类路径资源类似于程序包名称和完整类名称。 Since your packagename is "prova", your classpath resource is "prova/nurseRosteringBenchmarkConfig.xml". 由于您的程序包名称为“ prova”,因此您的类路径资源为“ prova / nurseRosteringBenchmarkConfig.xml”。

    PlannerBenchmarkFactory plannerBenchmarkFactory = PlannerBenchmarkFactory.createFromXmlResource(
            "prova/nurseRosteringBenchmarkConfig.xml");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Optaplanner-网站资源不存在 - Optaplanner - The Website resource does not exist Optaplanner 项目的非法参数异常,求解器配置在 class 加载程序中不作为类路径资源存在 - Illegal argument exception for Optaplanner project, solver config does not exist as a classpath resource in the class loader Spring 引导类路径:指定的资源不存在 - Spring boot classpath: The specified resource does not exist Grails Optaplanner中的求解器配置不存在错误 - The solver configuration does not exist error in grails optaplanner 类路径资源[classpath *:xxxxx.properties]无法打开,因为它不存在 - class path resource [classpath*:xxxxx.properties] cannot be opened because it does not exist 无法打开类路径资源[spring / config / BeanLocations.xml],因为它不存在 - classpath resource [spring/config/BeanLocations.xml] cannot be opened because it does not exist 类加载器如何在清单类路径中加载类引用? - How does a classloader load classes reference in the manifest classpath? 如果重复,Java中的Classloader如何知道要加载哪个文件资源? - How does the Classloader in Java know which file resource to load if there are duplicates? 如何从类加载器获取类路径? - How to get classpath from classloader? .classpath文件在新项目中不存在 - .classpath file does not exist in new projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM