使用maven在eclipse中构建struts项目,我有点不对劲

时间:2017-02-20 04:56:20

标签: struts2

在eclipse开始使用struts,我使用maven struts2-archetype-blank。当我运行mvn test时,会出现如下错误:

testHelloWorld(cn.jx.hw.learn.example.HelloWorldTest)  Time elapsed: 0.135 sec  <<< ERROR!
java.lang.NullPointerException
    at com.opensymphony.xwork2.ActionSupport.getLocale(ActionSupport.java:68)
    at com.opensymphony.xwork2.TextProviderSupport.getLocale(TextProviderSupport.java:329)
    at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:204)
    at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:119)
    at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:86)
    at cn.jx.hw.learn.example.HelloWorld.execute(HelloWorld.java:30)

1 个答案:

答案 0 :(得分:0)

将HelloworldTest.java与github中的struts-example进行比较后,我改变了

HelloWorld hello_world = new HelloWorld(); 成 container.inject(HelloWorld.class的); 事情是正确的。 mvn test不发布错误