2016-08-21 3 views
0

Je suis nouveau à OptaPlanner et je me concentre sur l'analyse comparative . J'ai commencé à jouer avec le benchmark en Eclipse. J'ai suivi la documentation (http://docs.jboss.org/optaplanner/release/6.4.0.Final/optaplanner-docs/html_single/index.html#buildAndRunAPlannerBenchmark), mais en essayant de courir, je suis arrivé cette erreur :Optaplanner - Le benchmarkConfigResource n'existe pas comme une ressource classpath dans le classLoader

Exception in thread "main" java.lang.IllegalArgumentException: The benchmarkConfigResource (prova/src/prova/nurseRosteringBenchmarkConfig.xml) does not exist as a classpath resource in the classLoader ([email protected]). 
    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) 

Peut-être que je fais quelque chose de mal en Java (j'ai besoin de l'examiner), alors voici ma Code:

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(); 
    } 
} 

Infos: J'ai placé le fichier nurseRosteringBenchmarkConfig.xml dans le paquet de la même ClasseJava (prova).

Nous vous remercions de votre aide. Les ressources de chemin de classe sont similaires aux noms de paquetages et aux noms de classe complets.

Répondre

0

Étant donné que votre nom de pack est "prova", votre ressource de chemin de classe est "prova/nurseRosteringBenchmarkConfig.xml".

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

Cela a fonctionné. Merci beaucoup. –