eclipse环境搭建及分布式
1.1JDK环境变量
1.2修改JDK环境变量
必须配置path:
;%JAVA_HOME%/bin
1. 3修改eclipse环境
1.配置JDK引入
2.关闭校验
3.修改字符集
4.配置Maven
5.添加maven环境配置文件
补充:
因为eclipse整合maven中存在问题.所以导入项目时,只拷贝src文件.和pom.xml即可.
2京淘环境搭建
2.1项目拆分后jar包如何管理
说明:采用jt-parent项目管理jar包,通过一个项目维护jar包的版本.如果将来需要对jar包进行升级,只需修改jt-parent项目即可.
2.2项目拆分后工具类如何管理
说明:根据分布式的思想,将项目进行垂直拆分,同时要想让整个服务调用松耦合,必须需要业务支撑系统的支持.一个jt-parent负载管理jar包,一个jt-common管理工具类.
2.3京淘架构设计
序号 项目名称 主要作用
1 jt-manage 京淘后台管理系统 负责商品的更新和维护
2 jt-web 京淘前台系统,主要负责商品的展现
3 jt-cart 京淘购物车系统,负责用户购物车信息维护
4 jt-sso 京淘单点登陆系统,实现session数据共享
5 jt-order 京淘订单系统,负责订单维护
6 jt-search 京淘项目的全文检索
7 jt-rabbitMQ 消息队列系统
8 jt-parent 负责jar包的管理和依赖
9 jt-common 管理工具类文件
2.4构建jt-parent项目
2.4.1项目创建的规则
Jt-parent pom类型
Jt-common jar类型
Jt-manage war类型
2.4.2创建项目
2.4.3导入jar包
<!-- 集中定义依赖版本号 -->
<properties>
<junit.version>4.10</junit.version>
<spring.version>4.1.3.RELEASE</spring.version>
<mybatis.version>3.2.8</mybatis.version>
<mybatis.spring.version>1.2.2</mybatis.spring.version>
<mybatis.paginator.version>1.2.15</mybatis.paginator.version>
<mysql.version>5.1.32</mysql.version>
<bonecp-spring.version>0.8.0.RELEASE</bonecp-spring.version>
<druid.version>1.0.29</druid.version>
<mapper.version>2.3.2</mapper.version>
<pagehelper.version>3.4.2</pagehelper.version>
<jsqlparser.version>0.9.1</jsqlparser.version>
<slf4j.version>1.6.4</slf4j.version>
<jstl.version>1.2</jstl.version>
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<joda-time.version>2.5</joda-time.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<jackson.version>2.4.2</jackson.version>
<httpclient.version>4.3.5</httpclient.version>
<jedis.version>2.6.2</jedis.version>
</properties>
<dependencies>
<!-- 单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
<version>${mybatis.paginator.version}</version>
</dependency>
<!-- MySql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!--引入阿里druid监控 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 通用Mapper -->
<dependency>
<groupId>com.github.abel533</groupId>
<artifactId>mapper</artifactId>
<version>${mapper.version}</version>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>${jsqlparser.version}</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp-spring</artifactId>
<version>${bonecp-spring.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Jackson Json处理工具包 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
</dependency>
<!-- 消息队列 -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
<!-- JSP相关 -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- 时间操作组件 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<!-- Apache工具组件 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- 文件上传组件 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<!-- jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<!--添加spring-datajar包 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<!-- 字符加密、解密 -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<!-- 数据校验 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
</dependencies>
2.5构建jt-common
2.5.1创建项目
2.5.2添加继承
2.5.3关于子父级依赖jar包问题
<dependencies>
<!--说明:
如果父级中定义的jar包的版本和子项目中定义的jar包版本冲突了,
则以自己定义的版本为准.该功能一般在解决复杂的jar包冲突时使用.
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
2.5.4关于工具类修改问题
2.6构建jt-manage
2.6.1构建项目
问题说明:如果创建的项目中只有一个资源文件夹,缺少main/test则修改JDK即可.
2.6.2添加继承
2.6.3添加依赖
2.7Tomcat插件
2.7.1Tomcat服务器引入后缺点
1.tomcat使用一段时间后启动越来越慢.
2.Tomcat在运行期,会生成一些临时文件.这些文件一般保存到硬盘
如果需要在window/Linux中启动多台tomcat服务器.必须修改对应的端口号 8080/8005/8009
2.7.2引入tomcat插件
<!--通过maven启动tomcat插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8091</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
2.7.3配置tomcat启动命令
添加源码:
2.7.4端口被占用问题
如果出错,表示端口被占用.需要重启服务.
3.水平拆分
3.1原理
说明:因为编辑超大型项目时,开发时会造成一个业务逻辑可能有多个人共同开发的现象.因为这样的开发编程耦合性较高,开发不易,所以进行项目的水平拆分.
根据项目的层级进行拆分.
View----Controller(war)----接口/Service(jar)----dao(jar)/mapper----pojo(jar)
3.2具体业务场景
Web-aa(聚合项目)
Web-aa-controller—war
Web-aa-service —jar
Web-aa-mapper —jar
Web-aa-pojo —jar
3.3创建父级项目
2.选择项目创建方式
3.新建项目名称
4.选择项目类型
3.4项目如何调用
依赖顺序:
Web-aa-controller—依赖-Service—依赖–mapper-依赖–pojo
因为maven中依赖是由传递性的.
3.5项目格式
打包时只需要将web-aa打包即可.