2016-04-08 20 views
1

私はhttp://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.htmlチュートリアルに従っています。Apache速度:org.apache.velocity.exception.ResourceNotFoundException

私のvmファイルは、私のクラスと同じフォルダに保管しています。 velocityドキュメントは、私は私が今持っていないJSP/servlet支援を必要と言うように

Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource

:私は次の例外を取得しています。

どこが間違っていますか?

PS:私はIntelliJ IDE

+0

テンプレートは、おそらくルートでの作業ディレクトリであることを確認しますIntelliJのモジュールの「実行」メニューの「構成の編集」をクリックして、ランタイム構成を再確認してください。 –

答えて

0

を使用していますソースコードで見て、あなたのVelocityエンジンにRuntimeConstants.RESOURCE_LOADERclasspath.resource.loader.classを設定してみてください:

VelocityEngine engine = new VelocityEngine(); 
engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); 
engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()) 

//this is at src/main/java level, tested with Netbeans 
Template yourTemplate = ve.getTemplate("yourTemplate.vm");