工作中上个项目用到了分布式,但是在开发过程中只是简单的注册调用,没有深入一点的理解,趁着项目结束,想着自己搭建一个简单的分布式框架试试。
为了拾起好久没用过的mybatis,所以我打算在spring+springMVC+mybatis的项目框架整成分布式。
那么,首先我们先用maven来搭建一个分模块的项目。
分布式SSM项目结构,整体项目结构如下
testDemo是我建的父模块,pom中主要是为了来管理子模块的依赖jar包的版本。(这里因为我其实项目已经搭好了,所以包括了整个项目都用到的jar包)
4.0.0
com.lwa.testDemo
testDemo
pom
1.0-SNAPSHOT
test-provider
test-consumer
test-api
test-common
UTF-8
1.0.1
5.1.21
4.2.5.RELEASE
3.3.0
1.3.0
1.7.21
1.1.7
1.2.12
1.7.5
0.1.2
2.5.3
3.4.10
0.8
2.9.0
1.8.4.RELEASE
2.7
2.5.1
3.0.0
1.8
UTF-8
${project.artifactId}
org.springframework
spring-core
${dep.ver.springframework}
commons-logging
commons-logging
org.springframework
spring-context
${dep.ver.springframework}
org.springframework
spring-context-support
${dep.ver.springframework}
org.springframework
spring-beans
${dep.ver.springframework}
org.springframework
spring-web
${dep.ver.springframework}
org.springframework
spring-webmvc
${dep.ver.springframework}
org.springframework
spring-jdbc
${dep.ver.springframework}
org.springframework
spring-tx
${dep.ver.springframework}
org.springframework
spring-aspects
${dep.ver.springframework}
com.alibaba
druid
${dep.ver.druid}
mysql
mysql-connector-java
${dep.ver.mysql}
org.mybatis
mybatis
${dep.ver.mybatis}
org.mybatis
mybatis-spring
${dep.ver.mybatis-spring}
com.github.pagehelper
pagehelper
${dep.ver.pagehelper}
org.slf4j
slf4j-api
${dep.ver.slf4j}
org.slf4j
log4j-over-slf4j
${dep.ver.slf4j}
org.slf4j
jcl-over-slf4j
${dep.ver.slf4j}
ch.qos.logback
logback-classic
${dep.ver.logback}
com.alibaba
dubbo
${dep.ver.dubbo}
spring
org.springframework
netty
org.jboss.netty
org.apache.zookeeper
zookeeper
${dep.ver.zookeeper}
log4j
log4j
com.101tec
zkclient
${dep.ver.zkclient}
log4j
log4j
redis.clients
jedis
${redis.version}
org.springframework.data
spring-data-redis
${spring.redis.version}
${center.project.name}
org.apache.maven.plugins
maven-resources-plugin
${plg.ver.maven-resources-plugin}
${encoding}
org.apache.maven.plugins
maven-compiler-plugin
2.5.1
${jdk.ver}
${encoding}
maven-source-plugin
${plg.ver.maven-source-plugin}
true
compile
jar
src/main/resources
true
test-api子模块,作为操作数据库层和存放实体类pom.xml
testDemo
com.lwa.testDemo
1.0-SNAPSHOT
4.0.0
test-api
org.mybatis
mybatis
org.mybatis
mybatis-spring
mysql
mysql-connector-java
com.alibaba
druid
src/main/java
**/*.xml
test-provider 操作业务逻辑模块pom.xml
testDemo
com.lwa.testDemo
1.0-SNAPSHOT
4.0.0
war
test-provider
com.lwa.testDemo
test-api
1.0-SNAPSHOT
compile
org.springframework
spring-core
commons-logging
commons-logging
org.springframework
spring-web
org.springframework
spring-context
org.springframework
spring-beans
org.springframework
spring-webmvc
org.springframework
spring-jdbc
org.springframework
spring-aspects
org.slf4j
slf4j-api
org.slf4j
log4j-over-slf4j
org.slf4j
jcl-over-slf4j
ch.qos.logback
logback-classic
com.alibaba
dubbo
spring
org.springframework
netty
org.jboss.netty
org.apache.zookeeper
zookeeper
log4j
log4j
com.101tec
zkclient
log4j
log4j
redis.clients
jedis
org.springframework.data
spring-data-redis
test-provider
org.apache.maven.plugins
maven-resources-plugin
2.7
UTF-8
org.apache.maven.plugins
maven-compiler-plugin
2.5.1
1.8
UTF-8
maven-source-plugin
3.0.0
true
compile
jar
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
8082
/provider
test-consumer 控制层pom.xml
testDemo
com.lwa.testDemo
1.0-SNAPSHOT
4.0.0
test-consumer
war
com.lwa.testDemo
test-api
1.0-SNAPSHOT
org.springframework
spring-core
commons-logging
commons-logging
org.springframework
spring-web
org.springframework
spring-context
org.springframework
spring-beans
org.springframework
spring-webmvc
org.springframework
spring-jdbc
org.slf4j
slf4j-api
org.slf4j
log4j-over-slf4j
org.slf4j
jcl-over-slf4j
ch.qos.logback
logback-classic
redis.clients
jedis
org.springframework.data
spring-data-redis
com.alibaba
dubbo
spring
org.springframework
netty
org.jboss.netty
org.apache.zookeeper
zookeeper
log4j
log4j
com.101tec
zkclient
log4j
log4j
test-consumer
org.apache.maven.plugins
maven-resources-plugin
2.7
UTF-8
org.apache.maven.plugins
maven-compiler-plugin
2.5.1
1.8
UTF-8
maven-source-plugin
3.0.0
true
compile
jar
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
8088
/demo