1.电商基于soa架构,使用dubbo逆向工程分页插件完成商品查询源码03笔记_第1页
1.电商基于soa架构,使用dubbo逆向工程分页插件完成商品查询源码03笔记_第2页
1.电商基于soa架构,使用dubbo逆向工程分页插件完成商品查询源码03笔记_第3页
1.电商基于soa架构,使用dubbo逆向工程分页插件完成商品查询源码03笔记_第4页
1.电商基于soa架构,使用dubbo逆向工程分页插件完成商品查询源码03笔记_第5页
免费预览已结束,剩余17页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

[今日课程大纲]

项目介绍开发环境搭建

完成

商品查询

[知识点详解]

一.

项目介绍

行业的几种模式.

1.

1.1B2B:企业到企业,商家到商家。代表:阿里巴巴、

网。

1.2B2C:商家到客户。代表:京东、淘宝商城(B2B2C)。

1.3C2C:客户到客户。淘宝集市。

1.4O2O:线上到线下。

2.技术选型

2.1Spring、SpringMVC、Mybatis

2.2JSP、JSTL、jQuery、jQueryplugin、EasyUI、KindEditor(富文本

编辑器)、CSS+DIV

2.3Redis(缓存服务器)

2.4Solr(搜索)

2.5Dubbo(调用系统服务)

2.6

2.7Nginx(web服务器)

2.8jsonp跨域数据请求格式

2.9nexus

maven

2.10MyBatis逆向工程

2.11HttpC nt 使用java完成请求及响应的技术.

分库分表技术

2.12MyCat

3.开发工具和环境

3.1Eclipsemars

3.2Maven3.3.3

3.3Tomcat7.0.79(MavenTomcatPlugin)

3.4JDK1.7

3.5

5.7

3.6Nginx1.8.0

3.7Redis3.0.0

3.8Win7操作系统

3.9Linux(服务器系统)

配置

4.

4.1产品经理:3人,确定需求以及给出产品原型图。

4.2项目经理:1人,项目管理。

4.3前端团队:5人,根据产品经理给出的原型制作静态页面。

4.4后端团队:20人,实现产品功能。

4.5测试团队:5人,测试所有的功能。

4.7运维团队:3人,项目的发布以及

5.项目周期:

6个月

5.1

6.整个

结构图

7.基于SOA架构

redis

二.数据库准备和逆向工程

1.直接运行SQL

.

2.使用逆向工程生成mapper和pojo

三.搭建maven环境

1.为什么使用Nexus搭建maven

的作用)

(

开发成员没有

,通过局域网连接nexus

,由私

1.1

服连接

dub ervice-impl

Dub ervice

redis

pojo

ord

manage

assport

commons

cart

item

search

portal

parent

1.2把项目发布到

.其他

.

2.使用

之后架构图

仓库

maven项目

nexus

3.搭建nexus的步骤

3.1nexus-2.12.0-01-bundle.zip解压到任意非中文目录中

3.2修改nexus端口(默认8081)

3.2.1nexus-2.12.0-01\conf\perties

3.3粘贴索引库(不配置无法搜索)

3.3.1先清空sonatype-work\nexus\indexer\central-ctx

内容

3.3.1把解压后的索引文件粘贴到这个文件夹中

3.4进入nexus-2.12.0-01\bin\jsw\windows-x86-64(对应自己系统)

3.4.1install-nexus.bat安装服务

3.4.2start-nexus.bat开启服务

3.4.3stop-nexus.bat停止服务

3.4.4uninstall-nexus.bat卸载服务

3.5在浏览器输入

3.6点击右侧login,输入用户名:admin,

:admin123

3.7在左侧搜索框中输入artifactid测试是否配置成功

4.使用maven连接

4.1前提:把maven环境搭建,并设置userssettings

settings.xml

4.2在settings.xml配置

4.2.1本地仓库路径

4.2.2配置jdk

< >

<id>jdk-1.7</id>

<activation>

<activeByDefault>true</activeByDefault>

<jdk>1.7</jdk>

</activation>

profile

<localRe itory>D:/maven/myre itory</localRe ito

>

ry

4.2.3配置

构建(连接

用的到jar等内容)

<profile>

<id>nexusTest</id>

<re itories>

<re itory>

<id>local-nexus</id>

<url>c/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<properties>

< piler.source>1.7< piler.source>

< piler. >1.7< piler. >

< pilerVer >1.7< piler

.compilerVer

</properties>

</ >

profile

4.2.4配置让

构建生效

nexusTest上面<profile>的<id>

4.2.5配置镜像,maven连接

<mirror>

<id>nexus-releases</id>

<mirrorOf>*</mirrorOf>

<url>c</url>

</mirror>

<mirror>

<id>nexu apshots</id>

<mirrorOf>*</mirrorOf>

<activeProfiles><!--激活id为nexusTest的profile-->

<activeProfile>nexusTest</activeProfile>

</activeProfiles>

<enabled>true</enabled>

</snapshots>

</re

</re itories>

</profile>

5.把项目发布到

的步骤

5.1在pom.xml中配置

路径

5.2在settings.xml中配置连接

仓库的用户名和

5.2.1<server>中<id>和pom.xml中<re

itory>中<id>对应

< >

server

<distributionManagement>

<re itory>

<id>releases</id>

<url>es/releases</url>

</re

<snapshotRe itory>

<id>snapshots</id>

<url>

e apshots</url>

</snapshotRe

</distributionManagement>

<url>

/apache-snapshots/</url>

</mirror>

5.3右键项目-->runas输入deploy

四.创建项目

1.创建六个项目

mons:放工具类等

1.1

项目

1.2ego-manage:

1.3ego-parent:父项目

1.4ego-pojo:实体类

1.5ego-service:服务接口

1.6ego-service-impl:dubbo的provider

<id>releases</id>

<username>admin</username>

<password>admin123</password>

</ >

<server>

<id>snapshots</id>

<username>admin</username>

<password>admin123</password>

</server>

server

2.把

页面放在ego-manage/WEB-INF中

3.在ego-manage编写控制器类

@Controller

publicclassPageController{@RequestMap ("/")publicString e(){

return"index";

}

@RequestMap ("{page}")

五.MyBatis分页插件

1.在mybatis.xml中配置<plugin>

,在程序员所编写的sql命令基础

上添加一些内容.

2.在pom.xml配置依赖

3.创建mybatis.xml并配置插件信息

<?xmlver ="1.0"encoding="UTF-8"?>

<!DOCTYPEconfiguration

PUBLIC"-//mybatis. //DTDConfig3.0//EN"

" ">

<!--分页插件-->

<dependency>

<grou >com. .pagehelper</grou >

<artifactId>pagehelper</artifactId>

<ver >4.1.6</ver

</dependency>

publicStringsho ge(@PathVariableStringpage){

returnpage;

}

}

4.在applicationContext.xml中配置加载mybatis.xml

5.编写代码时注意:PageHelper.startPage()写在查询全部上面.

PageHelper.startPage(page,rows);

<!--SqlSes Factory-->

<beanid="factory"

class=" .mybatis.spring.SqlSes

<propertyname="dataSource"ref="dataSource"></property>

<propertyname="typeAliasesPackage"value="com.ego.pojo"></property>

<propertyname="configLocation"value="classpath:mybatis.xml"></property>

</bean>

<configuration>

<plugins>

<plugin

erceptor="com. .pagehelp ageHelper">

<!--告诉分页插件是哪个数据库-->

<propertyname="dialect"value=" "/>

</plugin>

</plugins>

</configuration>

六.实现商品分页显示功能

1.在

mons中创建easyuidatagrid类

1.1把所有ego-pojo中类序列化

2.在ego-service中创建接口

public erfaceTbItemDub ervice{

/**

商品分页查询

@par age

publicclassEasyUIDataGridimplementsSerializable{

//当前页显示数据

priva ist<?>rows;

//总条数

priva ongtotal;

//查询全部List<TbItem>list=

tbItemMapper.selectByEx le(newTbItemEx le());

//分页代码

//设置分页条件

PageInfo<TbItem>pi=ne geInfo<>(list);

3.在ego-service-impl编写功能

publicclassTbItemDub erviceImplimplements

TbItemDub ervice{@Resource

privateTbItemMappertbItemMapper;@Override

publicEasyUIDataGridshow( page, rows){PageHelper.startPage(page,rows);

//查询全部List<TbItem>list=

tbItemMapper.selectByEx le(newTbItemEx le());

//分页代码

//设置分页条件

PageInfo<TbItem>pi=ne geInfo<>(list);

//放入到实体类

EasyUIDataGriddatagrid=newEasyUIDataGrid();

@paramrows

@return

*/

EasyUIDataGridshow( page, rows);

}

4.在ego-service-impl中applicationContext-dubbo.xml配置接口

5.编写Test类运行dubbo服务

6.在ego-manage添加TbItemService及实现类

public erfaceTbItemService{

/**

显示商品

@par age

@paramrows

publics icvoidmain(String[]args){Ma ain(args);

}

<dub ervice

erface="com.ego.dub ervice.TbItemDub ervice"

ref="tbItemDub erviceImpl"></dub ervice>

<bean id="tbItemDub

class="com.ego.dub ervice.impl.TbItemDub erviceImpl"></bean>

datagrid.setRows(pi.getList());datagrid.setTotal(pi.getTotal());returndatagrid;

}

}

7.在ego-manage里新建TbItemController

@Controller

publicclassTbItemController{@Resource

privateTbItemServicetbItemServiceImpl;

/**

*分页显示商品

*/

@RequestMap ("item/list")

*@return

*/

EasyUIDataGridshow( page, rows);

}

@Service

publicclassTbItemServiceImplimplementsTbItemService{@Reference

privateTbItemDub ervicetbItemDub@Override

publicEasyUIDataGridshow( page, rows){

returntbItemDub erviceImpl.sho ge,rows);

}

}

七.商品上架,下架,删除

1.在ego-service中TbItemDub

ervice接口及实现类添加

2.在

mons中添加EgoResult,做为java代码和jsp叫做公共类

/**

根据id修改状态

@paramid

@params us

@return

*/

updItemS us(TbItemtbItem);

@Override

public updItemS us(TbItemtbItem){

return

tbItemMapper.updateByPrimaryKeySelective(tbItem);

}

@ResponseBody

publicEasyUIDataGridshow( page,

returntbItemServiceImpl.sho

}

}

3.在ego-manage的TbItemService及实现类添加

/**

批量修改商品状态

@paramids

@params us

@return

*/

update(Stringids,bytes

@Override

public update(Stringids,bytes us){index=0;

TbItemitem=newTbItem();String[]idsStr=ids.split(",");for(Stringid:idsStr){

item.setId(Long.parseLong(id));item.setS us(s us);

index

+=tbItemDub erviceImpl.updItemS us(item);

}

if(index==idsStr.length){

publicclassEgoResult{

private s us;

4.在ego-manage中TbIt

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论