1.将工程改造为SOA架构

1.1分析

聚合工程必须有个war包

需要拆工程 一个服务层和表现层    

所有数据都是通过调用服务层获得的

需要把web层单独提取出来 提成一个独立的工程 也可以变成一个maven 工程、

第一步、需要在eclipse上把web引用模块删除(千万不要连本地的也删除)

第二步、把web工程剪切到外面和manager同级别

第三步、manager里面只包含service和dao

第四步、在eclipse上从manager上pom.xml配置上删除web的配置

第五步、把聚合工程manager中service改成war包的工程 (PS:跟之前web一样了 代替web工程)

第六步、如果不处理会报错 无相应的文件需要手动配置(出现?是新加的文件夹未被SVN处理,星号是改动的文件,红叉代表需要更新下,更新下就可以了)

第七步、把新处理的web加载到eclipse中(和manager聚合工程同级别所以pom.xml 中依赖的父工程需要改为parent,同时为了分开俩个模块,web将不需要依赖service层,只需要依赖接口就可以)

第八步、由于web不依赖service,spring的配置文件实在service中,所以需要在service中复制spring配置到web的pom.xml中

第九步、现在已经完全把一个工程分为两个工程了,由于各种配置在web中,而分开之后web将用不到多余的配置,需要把这样配置复制到service中,只留下web工程需要的配置即可

第十步、服务层没有表现层的东西所以解决乱码问题,service中用不到,只做到初始化一个spring容器,web层只需要留下一个springMVC

第十一步、目前俩个工程全部分开,由于web中只依赖接口,无实现类

1.1. 工程改造

1.1.1. 拆分工程

1)将表现层工程独立出来:

e3-manager-web

2)将原来的e3-manager改为如下结构

e3-manager

|--e3-manager-dao

|--e3-manager-interface

|--e3-manager-pojo

|--e3-manager-service(打包方式改为war)

1.1.2. 服务层工程

第一步:把e3-manager的pom文件中删除e3-manager-web模块。

第二步:把e3-manager-web文件夹移动到e3-manager同一级目录。

第三步:e3-manager-service的pom文件修改打包方式

<packaging>war</packaging>

第四步:在e3-manager-service工程中添加web.xml文件

第五步:把e3-manager-web的配置文件复制到e3-manager-service中。

删除springmvc.xml

第六步:web.xml 中只配置spring容器。删除前端控制器

第七步:发布服务

1、在e3-manager-Service工程中添加dubbo依赖的jar包。

<!-- dubbo相关 -->

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>dubbo</artifactId>

<exclusions>

<exclusion>

<groupId>org.springframework</groupId>

<artifactId>spring</artifactId>

</exclusion>

<exclusion>

<groupId>org.jboss.netty</groupId>

<artifactId>netty</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.apache.zookeeper</groupId>

<artifactId>zookeeper</artifactId>

</dependency>

<dependency>

<groupId>com.github.sgroschupf</groupId>

<artifactId>zkclient</artifactId>

</dependency>

2、在spring的配置文件中添加dubbo的约束,然后使用dubbo:service发布服务。

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd

http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">

<context:component-scan base-package="cn.e3mall.service"></context:component-scan>

<!-- 使用dubbo发布服务 -->

<!-- 提供方应用信息,用于计算依赖关系 -->

<dubbo:application name="e3-manager" />

<dubbo:registry protocol="zookeeper"

address="192.168.25.154:2181,192.168.25.154:2182,192.168.25.154:2183" />

<!-- 用dubbo协议在20880端口暴露服务 -->

<dubbo:protocol name="dubbo" port="20880" />

<!-- 声明需要暴露的服务接口 -->

<dubbo:service interface="cn.e3mall.service.ItemService" ref="itemServiceImpl" />

</beans>

1.1.3. 表现层工程

改造e3-manager-web工程。

第一步:删除mybatis、和spring的配置文件。只保留springmvc.xml

第二步:修改e3-manager-web的pom文件,

1、修改parent为e3-parent

2、添加spring和springmvc的jar包的依赖

3、删除e3-mangager-service的依赖

4、添加dubbo的依赖

<!-- dubbo相关 -->

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>dubbo</artifactId>

<exclusions>

<exclusion>

<groupId>org.springframework</groupId>

<artifactId>spring</artifactId>

</exclusion>

<exclusion>

<groupId>org.jboss.netty</groupId>

<artifactId>netty</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.apache.zookeeper</groupId>

<artifactId>zookeeper</artifactId>

</dependency>

<dependency>

<groupId>com.github.sgroschupf</groupId>

<artifactId>zkclient</artifactId>

</dependency>

5、e3-mangager-web添加对e3-manager-Interface的依赖。

第三步:修改springmvc.xml,在springmvc的配置文件中添加服务的引用。

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd

        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd

        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

<context:component-scan base-package="cn.e3mall.controller" />

<mvc:annotation-driven />

<bean

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="prefix" value="/WEB-INF/jsp/" />

<property name="suffix" value=".jsp" />

</bean>

<!-- 引用dubbo服务 -->

<dubbo:application name="e3-manager-web"/>

<dubbo:registry protocol="zookeeper" address="192.168.25.154:2181,192.168.25.154:2182,192.168.25.154:2183"/>

<dubbo:reference interface="cn.e3mall.service.ItemService" id="itemService" />

</beans>

第四步:在e3-manager-web工程中添加tomcat插件配置。

<build>

<plugins>

<!-- 配置Tomcat插件 -->

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat7-maven-plugin</artifactId>

<configuration>

<path>/</path>

<port>8081</port>

</configuration>

</plugin>

</plugins>

</build>

宜立方商城第二天心得相关推荐

  1. 淘淘商城宜立方商城第二天,关于查询商品,浏览器页面无法显示

    淘淘商城宜立方商城第二天,关于查询商品,浏览器页面无法显示 新手初学分布式集群和maven搭建容易遇到各种各样的错误,第一天项目就遇到个tomcat不报错但是启动不起来,停在log4j让我头疼了两天之 ...

  2. 宜立方商城 搭建Maven第一天心得

    1.0. 使用maven的好处 1.使用maven管理工程. 2.Jar包的管理 3.工程之间的依赖管理 4.自动打包 1.1. 后台工程搭建分析 Maven的常见打包方式:jar.war.pom P ...

  3. 宜立方商城—— 购物车增加、删除、修改数量、删除选中商品和清空购物车的实现

    1.  购物车的实现 1.1. 功能分析 1.购物车是一个独立的表现层工程. 2.添加购物车不要求登录.可以指定购买商品的数量. 3.展示购物车列表页面 4.修改购物车商品数量 5.删除购物车商品 模 ...

  4. 宜立方商城——搜索功能的实现

    搜索功能的实现 效果图 模块划分 需要的我们自己写dao层mapper层 dao层存在我们搜索的结果 /*** 商品搜索dao*/ @Repository public class SearchDao ...

  5. BrnShop开源网上商城第二讲:ASP.NET MVC框架

    BrnShop开源网上商城第二讲:ASP.NET MVC框架 原文:BrnShop开源网上商城第二讲:ASP.NET MVC框架 在团队设计BrnShop的web项目之初,我们碰到了两个问题,第一个是 ...

  6. 阅读《JavaScript设计模式》第二章心得

    阅读<JavaScript设计模式>第二章心得 面向对象编程 面向对象编程就是将你的需求抽象成一个对象.然后针对这个对象分析其特征(属性)与动作(方法).这个对象我们称之为类.面向对象编程 ...

  7. 电子报账系统源码_网上商城系统建设心得,轻松搞定选择困难

    当前,我们正处于一个互联网飞速发展的时代,特别是互联网电商的出现,给我们的生活带来了翻天覆地的变化,不出家门便可购买各种商品,不用再到处奔走寻找,通过网络便可快速下单,然后坐等送货上门.而这种便捷的消 ...

  8. (转)学习淘淘商城第二十二课(KindEditor富文本编辑器的使用)

    http://blog.csdn.net/u012453843/article/details/70184155 上节课我们一起学习了怎样解决KindEditor富文本编辑器上传图片的浏览器兼容性问题 ...

  9. 学习淘淘商城第二十三课(添加商品的实现)

    上节课我们一起学习了富文本编辑器的使用,这节课我们一起学习下商品添加的实现. 在item-add.jsp当中,当点击提交按钮后,会触发submitForm方法,如下图所示. 在提交表单前需要校验输入的 ...

最新文章

  1. 嵌入式开发中DSP与FPGA的关系
  2. 智能经济的动力,从人工智能到超级智能
  3. 知乎高赞:我的编程能力从什么时候开始突飞猛进的?
  4. 希望增加的BLOG功能(序)
  5. java log4j 多个文件_为什么log4j会记录到两个单独的文件? [重复]
  6. plsql 中的记录型变量和引用型变量
  7. linux安装joomla,安装Joomla
  8. 启动数据库报错(1)ORA-01157,ORA-01110
  9. access 增加字段 工具_Java效率工具之Lombok
  10. bkg bnc_BNC的完整形式是什么?
  11. iOS编写最简单的界面切换应用
  12. 上达最高精度,下到最快速度,Scaled-YOLOv4:模型缩放显神威
  13. JSF技术的相关网站和BBS
  14. 妲己机器人怎么升级固件_OnRobot新增爱普生川崎机器人套件、HEX固件升级
  15. ES6——rest参数
  16. Kali linux 2016.2(Rolling)之 Nessus安装及Plugins Download Fail 解决方法
  17. Linux的cat命令详解
  18. linux系统安装五笔输入法,Linux下安装五笔输入法
  19. js监听移动端手机横竖屏事件
  20. CAD2015 C#二次开发 字体变形

热门文章

  1. 判断回文串,最长回文串方法
  2. 条形码识别(3)——译码
  3. DDSM数据处理之PngWithOverlay 框出病灶区域
  4. python人工智能面试题爱奇艺面试题_【爱奇艺Python面试】爱奇艺大数据面试 python-看准网...
  5. c++跟踪调试怎么用 dev_DEVC++调试方法
  6. python培训班一般多少钱-Python培训班多少钱
  7. 使用 VirtualBox 虚拟机在电脑上运行 Android 系统,让电脑变安卓平板!
  8. 记录贴/阴阳师core loop
  9. Chrome浏览器插件安装说明
  10. core修改模型属性中的默认单位