五day01学习笔记 分布式垂直拆分系统 基于是三个maven项目 使用eclipse编译器

在这里插入图片描述
在这里插入图片描述

一、创建maven项目

在这里插入图片描述

二、配置pom文件

<!-- 集中定义依赖版本号 -->
	<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>
</project>

三、创建工具项目(jar类型的,quickstart)【后打包】

jt-common
在这里插入图片描述

四、创建父类 jt-parent【先打包】

在这里插入图片描述

五、创建jt-manager

在这里插入图片描述
在这里插入图片描述

继承和依赖的关系
继承:获取父级项目全部的jar包
依赖:某些项目中需要引入恩爱的jar包,所以采用依赖方式

六、使用Tomcat插件

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<port>8091</port>
					<path>/jt</path>
				</configuration>
			</plugin>
		</plugins>
</build>

放在manage.pom文件中

七、如何运行tomcat插件

run按钮选择run config…… 然后选择maven build --new
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

run!遇到了问题

遇到了问题:没能run成功。
原因:jt-manage没有打包成功。
解决:maven clean前两个已经打好的包,然后重新按照顺序打包:jt-parent/jt-common/jt-manage 然后run!

八、运行结果:

在这里插入图片描述

总结:

1.为何使用tomcat插件?【本文使用tomcat7】

①eclipse中整合tomcat时,运行配置繁琐.
②tomcat使用一段时间后,tomcat启动时间越来越长.
③因为里边的项目变多了,生成了大量的临时文件.造成启动慢
搭建tomcat集群时,必须修改端口 8005/8080/8009【端口不能被占用】

2.tocat插件有什么好处

tomcat插件在程序启动时,会开启单独的线程加载tomcat,在tomcat中部署的项目,只有在线程工作时才能正常访问.即使生成了大量的临时文件则也在内存中.当线程关闭(tomcat服务).
搭建tomcat集群时只需要修改8080端口即可.
即:每一次需要开启新的服务器只需要修改配置文件的端口号即可 pom中。项目中最多开5个。

2.3 Maven高级

2.3.1 Maven的jar包如何自动依赖

说明:Maven加载jar包的过程

  1. 根据POM文件的坐标首先到本地仓库/私服镜像中查询jar包.
  2. 在引入jar包文件之前,需要先加载该jar包的pom.xml文件,对其中依赖的jar包再次解析.
  3. 解析完成后.实现jar包的自动依赖.

2.3.2 Maven的jar包如何保证不被篡改

SHA1介绍:
安全哈希算法(Secure Hash Algorithm)主要适用于数字签名标准 (Digital Signature Standard DSS)里面定义的数字签名算法(Digital Signature Algorithm DSA)。对于长度小于2^64位的消息,SHA1会产生一个160位的消息摘要。当接收到消息的时候,这个消息摘要可以用来验证数据的完整性。在传输的过程中,数据很可能会发生变化,那么这时候就会产生不同的消息摘要。 SHA1有如下特性:不可以从消息摘要中复原信息;两个不同的消息不会产生同样的消息摘要,(但会有1x10 ^ 48分之一的机率出现相同的消息摘要,一般使用时忽略)。
王小云提出了密码哈希函数的碰撞攻击理论,即模差分比特分析法,提高了破解了包括MD5、SHA-1在内的5个国际通用哈希函数算法的概率;给出了系列消息认证码MD5-MAC等的子密钥恢复攻击和HMAC-MD5的区分攻击;提出了格最短向量求解的启发式算法二重筛法;设计了中国哈希函数标准SM3,该算法在金融、国家电网、交通等国家重要经济领域广泛使用。 [1]

junit-4.12的中就有md5和sha1可以保证jar包不被篡改

在这里插入图片描述

2.3.3 Mavenjar包依赖关系

如果parent项目中依赖jar包.但是自己项目同样依赖jar包则以自己的依赖为准.

2.3.4 如何解决jar包冲突问题

依赖A-----B.1.0.jar
依赖C-----B.2.0.jar

解决思路:去除低版本jar包.

2.3.5 如何确定jar包版本关系

说明:架构师准备项目时需要保证jar包版本匹配.
网址: http://mvnrepository.com/

注意:如果是水平拆分

那么分为
view Controller Service Dao POJO
对应
Controller : war
Service : jar
Dao : jar
POJO : jar
然而 父类是pom类型的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值