Rythm设置 home.template 配置项后运行报错 :报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

Rythm设置 home.template 配置项后运行报错 :报错

kun坤 2020-06-06 18:51:44 45

小白请教~~最近学习Rythm,跟着教程在做例子时报错。教程地址:http://rythmengine.org/doc/tutorial.md#env

代码如下:

import org.rythmengine.Rythm;
import java.util.*;

public class HelloWorld {
    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("home.template", "resources");
        Rythm.init(map);
        System.out.println(Rythm.render("helloworld.html", "World"));
    }
}


请问home.template是在配置文件中存在么,教程中没有提到这个配置在哪里。

报错信息空指针异常,具体如下:

run:
     [java] java.lang.NullPointerException
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
.java:194)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)

     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)

     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:288)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
tils.java:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1337)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1189
)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:758)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     [java] Caused by: java.lang.NullPointerException
     [java]     at org.rythmengine.resource.TemplateResourceManager.<init>(Templ
ateResourceManager.java:168)
     [java]     at org.rythmengine.RythmEngine.init(RythmEngine.java:636)
     [java]     at org.rythmengine.RythmEngine.<init>(RythmEngine.java:561)
     [java]     at org.rythmengine.Rythm.init(Rythm.java:97)
     [java]     at HelloWord.main(Unknown Source)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav
a:217)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
.java:152)
     [java]     ... 21 more
     [java] --- Nested Exception ---
     [java] java.lang.NullPointerException
     [java]     at org.rythmengine.resource.TemplateResourceManager.<init>(Templ
ateResourceManager.java:168)
     [java]     at org.rythmengine.RythmEngine.init(RythmEngine.java:636)
     [java]     at org.rythmengine.RythmEngine.<init>(RythmEngine.java:561)
     [java]     at org.rythmengine.Rythm.init(Rythm.java:97)
     [java]     at HelloWord.main(Unknown Source)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav
a:217)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
.java:152)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)

     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)

     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:288)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
tils.java:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1337)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1189
)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:758)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     [java] Java Result: -1

 

Java
分享到
取消 提交回答
全部回答(1)
  • kun坤
    2020-06-06 18:51:50

    我不能重现你这个问题呢?你的Rythm版本是多少?能把你的项目打个包放到网盘上让我看看吗?

    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程