maven多模块ssmfreemarker搭建总结.docx
《maven多模块ssmfreemarker搭建总结.docx》由会员分享,可在线阅读,更多相关《maven多模块ssmfreemarker搭建总结.docx(44页珍藏版)》请在冰点文库上搜索。
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文件
xsi=""
xsi:
schemaLocation="">
4.0.0
com.handsome
handsome
0.0.1-SNAPSHOT
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和handsome-web下创建二级模块
创建方法和上面一样.不在复述..
5.删除一些不要的目录和依赖
父项目不要依赖.吧dependencies标签干掉左侧mavendependencies目录就没有了.
Handsome删成这样
其他两个一级模块也删到这样简洁.
6.添加模块之间的依赖关系
在handsome-biz-manager中添加对handsome-biz-dao的依赖
在handsome-web-core中添加对handsome-biz-manager的依赖
在handsome-web-war中添加对handsome-web-core的依赖
最终项目就变成了这样:
2.ssm整合
1.将war项目转换成web项目
这样项目就可以添加到tomcat了
部署的少了依赖包
2.增加maven依赖到部署
3.修改整理pom文件
Handsomepom.xml
xmlversion="1.0"encoding="UTF-8"?
>
xsi=""xsi:
schemaLocation="">
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-bizpom.xml
xmlversion="1.0"encoding="UTF-8"?
>
xsi=""xsi:
schemaLocation="">
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-daopom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-biz
0.1
handsome-biz-dao
handsome-biz-dao
--junit测试包-->
junit
junit
4.11
test
--mybatis驱动包-->
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
--mysql驱动包-->
mysql
mysql-connector-java
${mysql.version}
--dbcp数据源-->
commons-dbcp
commons-dbcp
1.4
commons-pool
commons-pool
1.6
handsome-biz-managerpom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-biz
0.1
handsome-biz-dao
handsome-biz-dao
--junit测试包-->
junit
junit
4.11
test
--mybatis驱动包-->
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
--mysql驱动包-->
mysql
mysql-connector-java
${mysql.version}
--dbcp数据源-->
commons-dbcp
commons-dbcp
1.4
commons-pool
commons-pool
1.6
handsome-webpom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-biz
0.1
handsome-biz-dao
handsome-biz-dao
--junit测试包-->
junit
junit
4.11
test
--mybatis驱动包-->
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
--mysql驱动包-->
mysql
mysql-connector-java
${mysql.version}
--dbcp数据源-->
commons-dbcp
commons-dbcp
1.4
commons-pool
commons-pool
1.6
Handsome-web-corepom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-web
0.1
handsome-web-core
handsome-web-core
com.handsome
handsome-biz-manager
${project.version}
--freemarker依赖-->
org.freemarker
freemarker
${freemarker.version}
handsome-web-deploypom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-web
0.1
handsome-web-deploy
handsome-web-deploy
pom
handsome-web-warpom.xml
xmlversion="1.0"?
>
schemaLocation=""xmlns=""
xmlns:
xsi="">
4.0.0
com.handsome
handsome-web
0.1
handsome-web-war
handsome-web-war
war
com.handsome
handsome-web-core
${project.version}
4.编译项目
在
上选择maveninstall
如果有错,,整项目部署目录和web.xml文件
完成后可以看到tomcat中的变化
依赖包出现了.
5.整合思路
6.写一个简单功能代码
写一个简单功能代码.从dao到manager(service)到controller
Dao层新建userdao,userdo
Manager层
Controller层也就是handsome-web-core模块
Handsome-web-deploy
上面详细的列出了项目结构和具体代码
7.具体配置
Web.xml
xmlversion="1.0"encoding="UTF-8"?
>
xmlns:
xsi=""
xsi:
schemaLocation="
"version="3.0">
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:
spring/spring-mvc.xml
1
springmvc
/
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/handsome
handsome.loggingLevel=info
Springmvc.xml
xmlversion="1.0"encoding="UTF-8"?
>
xmlns:
xsi=""
xmlns:
context=""
xmlns:
mvc=""
xmlns:
aop=""
xmlns:
tx=""
xmlns:
p=""
xsi:
schemaLoca