-3

私のプロジェクトの何が問題なのですか。すべての依存関係をインポートしましたが、それでもエラーが出力されます:

出力エラー

インポートした依存関係のリストは次のとおりです

そして、ここに私のテストコードがあります:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package brouillon;

import controllers.RetardJpaController;
import entites.Retard;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import javax.persistence.Persistence;
import org.jxls.common.Context;
import org.jxls.util.JxlsHelper;

/**
 *
 * @author Vals
 */
public class Brouillon {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        RetardJpaController ctr = new RetardJpaController(Persistence.createEntityManagerFactory("BrouillonPU"));
        List<Retard> liste = ctr.findRetardEntities();
        try(InputStream is = Brouillon.class.getResourceAsStream("ressources/object_collection_template.xls")) {
            try (OutputStream os = new FileOutputStream("object_collection_output.xls")) {
                Context context = new Context();
                context.putVar("retards", liste);
                //JxlsHelper.getInstance().processTemplate(is, os, context);
                JxlsHelper jh = JxlsHelper.getInstance();
                jh.processTemplate(is, os, context);
            }
        }
    }

}
4

1 に答える 1

-1

これは私には正しくありません:

    try(InputStream is = Brouillon.class.getResourceAsStream("ressources/object_collection_template.xls")) {

スペルミスに注意してください: "ressources". ルックアップで行うにはこれで十分です。その 2 番目の「s」を取り出して、動作するかどうかを確認してください。

それよりも悪いかもしれません。リソースがコード ソースの場合、その内容は CLASSPATH にありますが、フォルダー自体はありません。その場合、必要なのはファイル名だけです。

実行時に使用する CLASSPATH を調べて、その内容を確認してください。そうすればはっきりします。

「すべての依存関係をインポートしました」 - これが最大の問題です。ほとんどの初心者や経験の浅いプログラマーは、「自分はすべて正しくやっているのに、なぜコンピューターは自分を迫害するのか?」という態度に陥ります。「私は何を間違えたのですか?」で始まり、終わる態度を採用すると、さらに速くなります。あなたの間違いを容赦なくチェックします。

于 2015-12-13T14:18:45.620 に答える