1、maven多模块ssmfreemarker搭建总结Ssm+maven+freemarker搭建1. 用maven创建多模块项目1.整个项目的结构|- handsome|-handsome-biz|-handsome-biz-dao 数据库层|-handsome-biz-manager 业务层|-handsome-web|-handsome-web-deploy 页面模板|-handsome-web-home 控制层|-handsome-web-war 用来运行,打包2.首先创建一个maven项目修改pom.xml文件 4.0.0 com.handsome handsome 0.0.1-SNAP
2、SHOT pom handsome UTF-8 junit junit 3.8.1 test 接下来创建的都是该项目的模块:我理解的模块是分级的.在本项目中分为两级 handsome-biz 和handsome-web 是一级. 其他为二级模块3.创建一级模块handsome-biz 和handsome-web在handsome项目上新建模块 完成后在handsome中pom.xml文件中可以看到,两个子模块修改两个一级模块的pom.xml文件的package 为 pom 准备创建二级模块将红框中不需要的删除, 新增packaing标签4.创建二级模块在handsome-biz 和 hands
3、ome-web下创建 二级模块创建方法和上面一样.不在复述.5.删除一些不要的目录和依赖父项目不要依赖. 吧dependencies标签干掉 左侧 maven dependencies 目录就没有了.Handsome 删成这样其他两个一级模块也删到这样简洁.6.添加模块之间的依赖关系在handsome-biz-manager中添加对 handsome-biz-dao的依赖在handsome-web-core中添加对handsome-biz-manager的依赖在handsome-web-war中添加对handsome-web-core的依赖最终项目就变成了这样:2.ssm整合1.将war项目转
4、换成web项目这样项目就可以添加到tomcat了部署的少了依赖包 2.增加maven依赖到部署3.修改整理pom文件Handsome pom.xml UTF-8 4.0.6.RELEASE 3.2.7 5.1.29 2.3.20 4.0.0 com.handsome handsome 0.1 pom handsome handsome-biz handsome-web Handsome-biz pom.xml UTF-8 4.0.6.RELEASE 3.2.7 5.1.29 2.3.20 4.0.0 com.handsome handsome 0.1 pom handsome handsome
5、-biz handsome-web Handsome-biz-dao pom.xml 4.0.0 com.handsome handsome-biz 0.1 handsome-biz-dao handsome-biz-dao junit junit 4.11 test org.mybatis mybatis $mybatis.version org.mybatis mybatis-spring 1.2.2 mysql mysql-connector-java $mysql.version commons-dbcp commons-dbcp 1.4 commons-pool commons-po
6、ol 1.6 handsome-biz-manager pom.xml 4.0.0 com.handsome handsome-biz 0.1 handsome-biz-dao handsome-biz-dao junit junit 4.11 test org.mybatis mybatis $mybatis.version org.mybatis mybatis-spring 1.2.2 mysql mysql-connector-java $mysql.version commons-dbcp commons-dbcp 1.4 commons-pool commons-pool 1.6
7、handsome-web pom.xml 4.0.0 com.handsome handsome-biz 0.1 handsome-biz-dao handsome-biz-dao junit junit 4.11 test org.mybatis mybatis $mybatis.version org.mybatis mybatis-spring 1.2.2 mysql mysql-connector-java $mysql.version commons-dbcp commons-dbcp 1.4 commons-pool commons-pool 1.6 Handsome-web-co
8、re pom.xml 4.0.0 com.handsome handsome-web 0.1 handsome-web-core handsome-web-core com.handsome handsome-biz-manager $project.version org.freemarker freemarker $freemarker.version handsome-web-deploy pom.xml 4.0.0 com.handsome handsome-web 0.1 handsome-web-deploy handsome-web-deploy pomhandsome-web-
9、war pom.xml 4.0.0 com.handsome handsome-web 0.1 handsome-web-war handsome-web-war war com.handsome handsome-web-core $project.version 4.编译项目在上选择 maven install如果有错, 整项目部署目录和web.xml文件完成后可以看到tomcat中的变化依赖包出现了.5.整合思路6.写一个简单功能代码写一个简单功能代码. 从dao到 manager(service) 到controllerDao层 新建userdao,userdoManager层Cont
10、roller层 也就是handsome-web-core模块Handsome-web-deploy 上面详细的列出了项目结构和具体代码7.具体配置Web.xml springmvc org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:spring/spring-mvc.xml 1 springmvc / welcome- Handsome-web-war中Config.properties#freemarker的配置#handsome.freemarker.templates=E:/eclipse_workspace/ssm_workspace/handsome/handsome-web/handsome-web-deploy/templates#log4j的配置#handsome.loggingRoot=/tmp/Logs/handsomehandsome.loggingLevel=infoSpringmvc.xmlbeans xmlns= xmlns:xsi= xmlns:context= xmlns:mvc= xmlns:aop= xmlns:tx= xmlns:p= xsi:schemaLoca