上一篇我们介绍《构建dubbo分布式平台-maven代码结构》,从今天开始,我们将对代码的每一个构建做详细的记录,能够帮助大家如何快速构建dubbo分布式企业架构。
导语:在dubbo分布式架构构建之前,请大家务必掌握maven的相关技能,因为架构中大量使用maven技术进行项目构建,有不熟的朋友可以在网上找一些资料学习。
1. 准备技能
开发语言:JAVA/J2EE
项目构建管理:Maven
持续集成方案:Jenkins
SOA服务: Dubbo、zookeeper、Restful
SSO单点登录:Redis、JWT、Restful
分布式缓存:Redis
分布式消息中间件:zookeeper+kafka
分布式文件:FastDFS
数据库连接池:Alibaba Druid
核心框架:Spring framework、Spring MVC、Apache Shiro、MyBatis
前端框架:Bootstrap + html5 + CSS3
2. 创建maven基础项目,其中只需要配置pom.xml文件和打包的文件即可,代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sml.sz</groupId>
<artifactId>ant-project</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>ant-project</name>
<url>http://maven.apache.org</url>
<inceptionYear>2015-2016</inceptionYear>
<properties>
<!-- 框架通用包版本设置 -->
<spring.version>4.2.2.RELEASE</spring.version>
<validator.version>5.1.1.Final</validator.version>
<mybatis.version>3.2.8</mybatis.version>
<mybatis-spring.version>1.2.2</mybatis-spring.version>
<shiro.version>1.2.3</shiro.version>
<druid.version>1.0.11</druid.version>
<ehcache.version>2.6.9</ehcache.version>
<ehcache-web.version>2.0.4</ehcache-web.version>
<sitemesh.version>2.4.2</sitemesh.version>
<activiti.version>5.15.1</activiti.version>
<wink.version>1.4</wink.version>
<sso.client.version>3.2.1</sso.client.version>
<!-- 通用工具包版本设置 -->
<slf4j.version>1.7.7</slf4j.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-io.version>2.4</commons-io.version>
<commons-codec.version>1.9</commons-codec.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<commons-beanutils.version>1.9.1</commons-beanutils.version>
<jackson.version>2.2.3</jackson.version>
<fastjson.version>1.1.40</fastjson.version>
<xstream.version>1.4.7</xstream.version>
<guava.version>17.0</guava.version>
<dozer.version>5.5.1</dozer.version>
<email.version>1.4.7</email.version>
<poi.version>3.9</poi.version>
<freemarker.version>2.3.20</freemarker.version>
<!-- 基础环境设置 -->
<jdk.version>1.6</jdk.version>
<tomcat.version>2.2</tomcat.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<downloadSources>true</downloadSources>
<!-- jdbc驱动版本设置 -->
<mysql.driver.version>5.1.30</mysql.driver.version>
</properties>
<dependencies>
<!-- 单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- Tomcat 如果存在就不需要将servlet-api.jar、jsp-api.jar一起打包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!-- ant 工具jar -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-utils</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant 公共配置jar -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-config</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant 核心框架jar -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-framework</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant 代码自动生成业务jar -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-core-gen</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant 会员业务jar -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-core-member</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant RestFul服务系統 -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-web-service</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ant admin后台管理系統 -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-web-admin</artifactId>
<version>${project.version}</version>
</dependency>
<!-- dubbo begin -->
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-member-facade</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.sml.sz</groupId>
<artifactId>ant-member-service</artifactId>
<version>${project.version}</version>
</dependency>
<!-- dubbo end -->
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- maven -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<!-- 去除临时文件 -->
<excludes>
<exclude>**/*.keep</exclude>
<exclude>**/*.keep.*</exclude>
<exclude>*.bak</exclude>
<exclude>*.contrib</exclude>
</excludes>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:unchecked,deprecation,fallthrough,finally</compilerArgument>
<fork>true</fork>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<!-- 去除临时文件 -->
<excludes>
<exclude>**/*.keep</exclude>
<exclude>**/*.keep.*</exclude>
<exclude>*.bak</exclude>
<exclude>*.contrib</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<inputEncoding>${project.build.sourceEncoding}</inputEncoding>
<outputEncoding>${project.build.sourceEncoding}</outputEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeResources>false</excludeResources>
<attach>true</attach>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<version>5</version>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<configuration>
<parallel>both</parallel>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 读取系统配置的properties文件,避免写入profile中,各自模块使用的时候注意修改路径 -->
<plugin>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<locations>
<location>${basedir}/../project_${profile}.properties</location>
</locations>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<project>
dev
</project>
</properties>
</profile>
<profile>
<id>sit</id>
<activation>
<property>
<name>environment.type</name>
<value>sit</value>
</property>
</activation>
<properties>
<project>
sit
</project>
</properties>
</profile>
<profile>
<id>uat</id>
<activation>
<property>
<name>environment.type</name>
<value>uat</value>
</property>
</activation>
<properties>
<project>
uat
</project>
</properties>
</profile>
<profile>
<id>performance</id>
<activation>
<property>
<name>environment.type</name>
<value>performance</value>
</property>
</activation>
<properties>
<project>
performance
</project>
</properties>
</profile>
<profile>
<id>production</id>
<activation>
<property>
<name>environment.type</name>
<value>production</value>
</property>
</activation>
<properties>
<project>
production
</project>
</properties>
</profile>
</profiles>
<modules>
<!-- ant 工具jar -->
<module>ant-utils</module>
<!-- ant 公共配置jar -->
<module>ant-config</module>
<!-- ant 核心框架jar -->
<module>ant-framework</module>
<!-- ant 代码自动生成业务jar -->
<module>ant-core-gen</module>
<!-- ant 会员业务jar -->
<module>ant-core-member</module>
<!-- ant admin后台管理系統 -->
<module>ant-web-admin</module>
<!-- ant Restful服务管理系統 -->
<module>ant-web-service</module>
<!-- ant member Dubbo服务接口 -->
<module>ant-member-facade</module>
<!-- ant member Dubbo服务提供者 -->
<module>ant-member-service</module>
</modules>
<description>ant平台的super工程,定义了整合ant项目群的基本信息,以及依赖项和插件信息、maven的自定义信息</description>
</project>
2. 创建打包脚本:测试、生成等
build_SIT-no-test.bat
set MAVEN_OPTS= -Xms128 -Xmx256m
mvn clean package --define maven.test.skip=true --define environment.type=sit
build_UAT-no-test.bat
set MAVEN_OPTS= -Xms128 -Xmx256m
mvn clean package --define maven.test.skip=true --define environment.type=uat
build_PROD-no-test.bat
set MAVEN_OPTS= -Xms128 -Xmx256m
mvn clean package --define maven.test.skip=true --define environment.type=pro
3. 创建打包的properties文件:
project_sit.properties
解释: 里面可以配置打包的信息,比如:ip、域名、包名等
4. 代码结构如下:
欢迎大家跟我一起学习《构建dubbo分布式平台》,希望大家持续关注后面的文章!
相关推荐
maven构建的spring分布式服务,使用dubbo分布式部署,压缩包包含两个eclipse工程(spring-client和spring-server),解压后在eclipse中直接运行(注意:是maven工程),压缩包也包含dubbo-admin和zookeeper,本工程...
基于dubbo、SpringMVC、maven构建的分布式项目,分模块
Maven(模块化构建) Spring(IOC DI 声明式事务处理) SpringMVC(支持Restful风格) Hibernate Validate(参数校验) Mybatis(最少配置方案) Quartz时间调度 Redis缓存(ProtoStuff序列化) Redis Sentinel主从...
springboot、Dubbo、MySQL,源码web系统,框架,代码均经过严格测试,可直接运行,有需要可自取
第07节--使用maven构建dubbo服务的可执行jar包 第08节--在linux操作系统上手工部署dubbo服务 第09节--构建dubbo服务消费者web应用的war包并在tomcat中部署 第10节--dubbo监控中心的介绍与简易监控中心的安装 第11节...
| Maven | 项目构建管理 | | dubbo|分布式服务框架| # 系统功能 | **序号** | **功能** | **是否完成**| | ------------- |:-------------:| -------------:| |0.|框架相关功能| |0.1.|登录和权限验证|| |0.2.|...
分布式电商平台,基于SpringMVC开发,其他相关技术,Mybatis(开源ORM框架),Mybatis-Plus(国产ORM辅助包),Dubbo(阿里巴巴开源分布式服务框架),Zookeeper(分布式协调),Redis (高效KV),ActiveMQ(消息...
java分布式集群电商平台搭建文档demo,环境集群搭建dubbo、rabbitMQ 、redis 集群、mysql集群 、nginx负载、tomcat、zookeeper集群、maven项目构建示例
项目使用Maven构建,便于项目管理,可支持Oracle,MySql等主流数据库。项目初步分类明确,代码规范,便于后续维护等工作。前端展示界面采用基于Boostrap实现的响应式布局,并集成了一系列的动画效果插件,整体界面...
Maven | 项目构建管理 | [http://maven.apache.org/](http://maven.apache.org/) #### 前端技术: 技术 | 名称 | 官网 ----|------|---- jQuery | 函式库 | [http://jquery.com/](http://jquery.com/) Bootstrap | ...
14、 项目开发采用团队式的开发,统一使用Maven私服构建项目,使用统一的SVN服务进行代码的管理。 【课程内容】 项目功能实现分析 RESTful Web Service、SVN 项目讲解、环境搭建 后台系统功能实现 前台系统搭建、...
简讯基础框架Spring + Spring MVC + Mybatis分布式框架dubbo消息系统缓存redis构建工具
使用 Maven 构建父子模块, 使用 Git 进行版本控制 毕业设计基于SSM的健康管理系统源码+数据库(高分项目).zip该项目是个人高分毕业设计项目源码,已获导师指导认可通过,都经过严格调试,确保可以运行!放心下载...
1. SpringBoot Starter:他将常用的依赖分组进行了整合,将其合并到一个依赖中,这样就可以一次性添加到项目的Maven或Gradle构建中。 2,使编码变得简单,SpringBoot采用 JavaConfig的方式对Spring进行配置,并且...
java背诵简历-专业技能-背完就是10k 简历上的专业技能填写: 1. 具备扎实的Java基础,深入理解OOP编程思想...10. 了解分布式系统构建,接触过Dubbo、SpringCloud分布式管理框架 11. 了解shiro,SpingSecurity等安全框架
此项目整体采用springMVC + RESTFUL风格,mybatis持久层框架,采用springcloud dubbo实现服务分布式服务调用,服务注册发现使用nacos服务器。 本项目扩展了秒杀功能,集成了jmock完成服务层的测试,支持数据库分库...
1.开发环境采用Maven实施多模块项目构建,采用Git进行项目版本管理; 2.采用SpringBoot简化商城系统的初始搭建以及开发过程;项目使用Dubbo完成微服务架构,使用Zookeeper实现服务注册; 3.项目后台管理系统使用Shiro...
前后分离,前端vue,后端dubbo微服务, 使用技术有* Spring Boot 2.x * Maven构建项目 * Jenkins持续集成 * Dubbo RPC框架 * Apollo统一配置中心 * Spring + Spring MVC + MyBatis SSM框架 * druid数据库连接池 * ...
使用 Maven 构建父子模块, 使用 Git 进行版本控制 <项目介绍> 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! 1、该资源内项目代码都经过测试运行...