一 工程介绍
该工程是一个基于Spring+SpringMVC+Mybatis的电商项目,项目采用多模块化来实现,具体实现如下图所示
二 创建工程步骤
-
1.首先创建一个普通的项目文件夹
Mall
,里面存放该项目的所有工程 -
2.创建
mall-parent
父类工程,后面所有的工程全部继承该工程-
创建maven项目:file-->New-->Project-->Maven
-
- mall-parent:pom.xml
4.0.0
com.mall
mall-parent
1.0-SNAPSHOT
../mall-common
../mall-manager
../mall-web
pom
4.12
4.2.4.RELEASE
3.2.8
1.2.2
1.2.15
5.1.32
1.6.4
2.4.2
1.0.9
4.3.5
1.2
2.5
2.0
2.5
3.3.2
1.3.2
3.3
3.4.2
0.9.1
1.3.1
2.7.2
4.10.3
2.5.3
3.4.7
0.1
5.11.2
2.3.23
2.2.2
joda-time
joda-time
${joda-time.version}
org.apache.commons
commons-lang3
${commons-lang3.version}
org.apache.commons
commons-io
${commons-io.version}
commons-net
commons-net
${commons-net.version}
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
org.apache.httpcomponents
httpclient
${httpclient.version}
org.quartz-scheduler
quartz
${quartz.version}
junit
junit
${junit.version}
test
org.slf4j
slf4j-log4j12
${slf4j.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
${mybatis.spring.version}
com.github.miemiedev
mybatis-paginator
${mybatis.paginator.version}
com.github.pagehelper
pagehelper
${pagehelper.version}
mysql
mysql-connector-java
${mysql.version}
com.alibaba
druid
${druid.version}
org.springframework
spring-context
${spring.version}
org.springframework
spring-beans
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-aspects
${spring.version}
org.springframework
spring-jms
${spring.version}
org.springframework
spring-context-support
${spring.version}
jstl
jstl
${jstl.version}
javax.servlet
servlet-api
${servlet-api.version}
provided
javax.servlet
jsp-api
${jsp-api.version}
provided
commons-fileupload
commons-fileupload
${commons-fileupload.version}
redis.clients
jedis
${jedis.version}
org.apache.solr
solr-solrj
${solrj.version}
com.alibaba
dubbo
${dubbo.version}
org.apache.zookeeper
zookeeper
${zookeeper.version}
com.github.sgroschupf
zkclient
${zkclient.version}
org.apache.activemq
activemq-all
${activemq.version}
org.freemarker
freemarker
${freemarker.version}
${project.artifactId}
org.apache.maven.plugins
maven-resources-plugin
2.7
UTF-8
org.apache.maven.plugins
maven-compiler-plugin
3.7.0
1.8
UTF-8
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
-
3.创建
mall-common
通用的工程, 打包方式jar- 在
mall-parent
文件上右击创建新的model,和创建maven类似不需要勾选信息,然后会出现如下如下界面
- 在
- mall-common:pom.xml
mall-parent
com.mall
1.0-SNAPSHOT
../mall-parent/pom.xml
4.0.0
mall-common
joda-time
joda-time
org.apache.commons
commons-lang3
org.apache.commons
commons-io
commons-net
commons-net
com.fasterxml.jackson.core
jackson-databind
org.apache.httpcomponents
httpclient
org.quartz-scheduler
quartz
junit
junit
test
org.slf4j
slf4j-log4j12
-
4.创建
mall-manager
服务层工程、聚合工程、pom工程- 创建工程类似
mall-common
的过程不在演示 - mall-manager:pom.xml
- 创建工程类似
mall-parent
com.mall
1.0-SNAPSHOT
../mall-parent/pom.xml
4.0.0
mall-manager
pom
mall-manager-dao
mall-manager-entity
mall-manager-interface
mall-manager-service
mall-common
com.mall
1.0-SNAPSHOT
org.apache.tomcat.maven
tomcat7-maven-plugin
/
8091
-
5.创建
mall-manager-dao
、- 在
mall-manager
上右键创建,过程类似mall-common
的创建但是路径选择需要重写填写,如下图
- mall-manager-dao:pom.xml
- 在
mall-manager
com.mall
1.0-SNAPSHOT
4.0.0
mall-manager-dao
mall-manager-entity
com.mall
1.0-SNAPSHOT
org.mybatis
mybatis
org.mybatis
mybatis-spring
com.github.miemiedev
mybatis-paginator
com.github.pagehelper
pagehelper
mysql
mysql-connector-java
com.alibaba
druid
- mall-manager-entity:pom.xml
mall-manager
com.mall
1.0-SNAPSHOT
4.0.0
mall-manager-entity
- mall-manager-interface:pom.xml
mall-manager
com.mall
1.0-SNAPSHOT
4.0.0
mall-manager-interface
mall-manager-entity
com.mall
1.0-SNAPSHOT
-
mall-manager-service 创建时要创建webapp/WEB-INF/web.xml
mall-manager
index.jsp
- mall-manager-service:pom.xml
mall-manager
com.mall
1.0-SNAPSHOT
4.0.0
mall-manager-service
war
mall-manager-dao
com.mall
1.0-SNAPSHOT
org.springframework
spring-context
org.springframework
spring-beans
org.springframework
spring-webmvc
org.springframework
spring-jdbc
org.springframework
spring-aspects
org.springframework
spring-jms
org.springframework
spring-context-support
-
6.创建mall-web 表现层
- mall-web:pom.xml
mall-parent
com.mall
1.0-SNAPSHOT
../mall-parent/pom.xml
4.0.0
mall-web
war
com.mall
mall-common
1.0-SNAPSHOT
com.mall
mall-manager-interface
1.0-SNAPSHOT
org.springframework
spring-context
org.springframework
spring-beans
org.springframework
spring-webmvc
org.springframework
spring-jdbc
org.springframework
spring-aspects
org.springframework
spring-jms
org.springframework
spring-context-support
jstl
jstl
javax.servlet
servlet-api
provided
javax.servlet
jsp-api
provided
com.alibaba
dubbo
spring
org.springframework
netty
org.jboss.netty
org.apache.zookeeper
zookeeper
com.github.sgroschupf
zkclient
org.apache.tomcat.maven
tomcat8-maven-plugin
/
8090
到此为止已经创建好了项目结构,创建的目录结构如下所示
三 通过tomcat插件启动项目
- 这个配置已经在mall-web:pom.xml中配置,无需再配置
org.apache.tomcat.maven
tomcat8-maven-plugin
/
8090
-
首先运行mall-parent-->install
-
然后运行mall-web -->tomcat7:run
- 然后运行mall-manager -->tomcat7:run 启动方式如mall-web
-
项目启动成功
- 在地址栏输入:localhost:8090(默认是8080)
-
在地址栏输入:localhost:8091(默认是8080)
代码GitHub地址:project-Mall
所属文集:技术栈