1. 程式人生 > >maven+ssh struts2+spring編譯不成功的問題

maven+ssh struts2+spring編譯不成功的問題

Action配置到spring中,一直報action找不到的錯誤,struts2.xml中加入<constant name="struts.objectFactory" value="spring"></constant>,又會報其他各種錯誤:Cannot locate the chosen ObjectFactory implementation: spring 。

網上解決的辦法是:1、缺少  struts2-spring-plugin  2、Action名字不一致。

但百思不得其解,用maven導包,沒有少什麼。直到百度java struts2中的action如何交由spring管理,發現知道里有人回答

注意看struts2-spring-plugin裡面的struts-plugin.xml,可以判斷是否需要新增

<constant name="struts.objectFactory" value="spring"> 就可識別。。。檢視maven的struts2-spring-plugin包裡,並無此檔案,

就猜到可能是本地倉庫的jar包問題,替換成正常的jar包,果然有用。