轉自http://www.diybl.com/course/3_program/java/javajs/2008513/115765.html
寫這個還是怕以后忘了。作個備案。供學習和改進:
命令行創(chuàng)建webapp項目:
mvn archetype:create -DgroupId=com.actioner.ssh2 -DartifactId=ssh2 -DarchetypeArtifactId=maven-archetype-webapp
會創(chuàng)建一個叫ssh2的maven web工程。
手動補足test及其下的java resources filters等及main下的java目錄
mvn -Declipse.workspace=d:\projects eclipse:add-maven-repo
mvn eclipse:eclipse
在eclipse中配置配置好tomcat,并將ssh2.xml文件放到tocmat的conf\catalian\localhost下.ssh2.xml內容如下:
<Context path="/ssh2" docBase="D:\projects\ssh2\target\ssh2" debug="0" privileged="true" reloadable="false" workDir="D:\projects\ssh2\target\ssh2\tmp"></Context>
在eclipse中導入ssh2工程
啟動tomcat.在ie中輸入url:http://localhost:8080/ssh2
如果出現(xiàn)“Hello World”
則OK!!
繼續(xù):
在pom.xml中增加對hibernate3.25.ga spring2.06 struts2.09-core包的依賴??山柚鷈clipse插件實現(xiàn)
在web.xml中增加struts2框架,并在src\main\resources中增加struts.xml 可以將appfuse項目中的copy過來做為模板
在 web.xml中增加spring框架,并在src\main\resources中增加 ApplicationResources.properties ApplicationResources_zh_CN.properties log4j.xml 等資源文件。均可以將appfuse項目中的copy過來做為模板
applicationContext.xml必須放在src\main\webapp\web-inf下
在applicationContext.xml中一定要設置dataSource和sessionFactory否則會報錯。mysql數(shù)據(jù)庫和數(shù)據(jù)庫連接池的依賴包也要加載到pom.xml中
Cannot locate the chosen ObjectFactory implementation: spring 要加載struts2-spring.plugs.jar到pom.xml