當 struts2 加入 struts2-spring-plugin 的 JAR 檔後,執行 JUnit 或 Maven build 時發生
SEVERE: [50:59.081] ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ********** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> SEVERE: [50:59.089] Dispatcher initialization failed |
這時候 JUnit 程式的 extends 要由 StrutsTestCase 變為 StrutsSpringTestCase ,這樣才不會出錯。程式碼如下
package com.mis.example; //public class HelloWorldTest extends StrutsTestCase{ |
參考:
http://blog.csdn.net/zj133520/article/details/12620763
http://kang36897.blog.163.com/blog/static/170473732010710101238126/
http://openhome.cc/Gossip/JUnit/
http://linuschien.blogspot.tw/2013/01/unit-test-to-struts2-action-with-spring.html
留言列表