栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

PigCloud项目的使用解析一

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PigCloud项目的使用解析一

1.项目结构




2.父模块分析

pom.xml:





	4.0.0

	
		
		com.pig4cloud
		pig-cloud-dependencies-parent
		3.1.1
	

	com.pig4cloud
	pig
	3.1.1
	${project.artifactId}
	pom
	https://www.pig4cloud.com

	
		3.15.4
		2.0.3.RELEASE
		3.8.0
		1.28
		0.9.6
		1.68
		2.16.0

		2.4.4
		2020.0.2
		2021.1
		UTF-8
		1.8
		1.8
		2.3.1
		5.6.3
		3.4.2
		3.3.2
		2.2.0
		1.7
		1.10
		2.0.0
		2.1.0
		3.0.2
		2.3.0
		0.36.1
		http://192.168.7.206:2375
		http://47.106.103.68:5005
		rbs_mc3
		admin
		Harbor12345
		2.12.1
		0.4.1
		5.7.5
		2.5.2
		2.1.3
		3.4.3
		0.0.4
		2.15.0
	

	
		
		
			org.springframework.cloud
			spring-cloud-starter-bootstrap
		
		
		
			org.springframework.boot
			spring-boot-configuration-processor
			true
		
		
		
			com.github.ulisesbocchio
			jasypt-spring-boot-starter
			${jasypt.version}
		
		
		
			org.springframework.boot
			spring-boot-starter-actuator
		
		
		
			de.codecentric
			spring-boot-admin-starter-client
			${spring-boot-admin.version}
		
		
		
			org.projectlombok
			lombok
			provided
		
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
	

	
		pig-register
		pig-gateway
		pig-auth
		pig-upms
		pig-common
		pig-visual
		mc-inner-conn
		mc-res-center
		mc-edu
		mc-out-tran
		mc-auth-third
    mc-file
    

	
		
			
				com.pig4cloud
				mc-common-swagger
				${project.version}
			
			
			
				org.springframework.boot
				spring-boot-dependencies
				${spring-boot.version}
				pom
				import
			
			
			
				org.springframework.cloud
				spring-cloud-dependencies
				${spring-cloud.version}
				pom
				import
			
			
			
				com.alibaba.cloud
				spring-cloud-alibaba-dependencies
				${spring-cloud-alibaba.version}
				pom
				import
			

			
			
				com.alibaba
				transmittable-thread-local
				${transmittable-thread-local.version}
			

			
			
				com.pig4cloud.excel
				excel-spring-boot-starter
				${excel-spring-boot-starter.version}
			

			
			
				net.dreamlu
				mica-core
				${mica-core.version}
			
			
				net.dreamlu
				mica-xss
				${mica-core.version}
			

			
				org.dom4j
				dom4j
				${dom4j.version}
			

			
			
				org.apache.cxf
				cxf-rt-transports-http
				${cxf.version}
				
					
						spring-web
						org.springframework
					
				
			

			
				org.apache.cxf
				cxf-rt-frontend-jaxws
				${cxf.version}
				
					
						wstx-asl
						org.codehaus.woodstox
					
				
			

			
				com.pig4cloud.plugin
				idempotent-spring-boot-starter
				${idempotent-spring-boot-starter.version}
			


			
			
				org.redisson
				redisson-spring-boot-starter
				${redisson-spring-boot-starter.version}
				
					
						org.springframework.boot
						spring-boot-starter-web
					
				
			

			
			
				io.github.biezhi
				TinyPinyin
				${tinypinyin.version}
			

			
			
				commons-net
				commons-net
				${commons-net.version}
			

			
			
				org.yaml
				snakeyaml
				${yaml.version}
			

			
			
				com.github.odiszapc
				nginxparser
				${nginxparser.version}
			

			
			
				org.bouncycastle
				bcpkix-jdk15to18
				${bcpkix-jdk15to18.version}
			

			
			
				com.drewnoakes
				metadata-extractor
				${metadata-extractor.version}
			

			
			
				org.apache.logging.log4j
				log4j-api
				${log4j2.version}
			

			
				org.apache.logging.log4j
				log4j-to-slf4j
				${log4j2.version}
			

		
	

	
		${project.name}
		
			
				src/main/resources
				true
			
		
		
			
				
					org.springframework.boot
					spring-boot-maven-plugin
					${spring-boot.version}
					
						
							repackage
							
								repackage
							
							package
							
								${project.build.finalName}
								
									true
								
							
						
						
					
					
				

				
					io.fabric8
					docker-maven-plugin
					${docker.plugin.version}
					
						
						${docker.host}
						
						${docker.registry}
						
						
							
								${docker.username}
								${docker.password}
							
						
						
							
								47.106.103.68:5005/${docker.namespace}/${project.name}:latest
								
									true
									${project.basedir}
                   
								
							
						
					
				

				
					org.apache.maven.plugins
					maven-assembly-plugin
					false
					
						${project.name}
						
							${project.basedir}/assembly/assembly.xml
						
					
					
						
							make-assembly
							
							package
							
								
								single
							
						
					
				
			
		

		
			
				io.fabric8
				docker-maven-plugin
				
					true
				
			

			
				org.apache.maven.plugins
				maven-resources-plugin
				2.5
				
					UTF-8
					
						xlsx
						xls
					
				
			

		

	

	
		
			dev
			
				
				dev
			
			
				
				true
			
		
	



docker-compose.yml:

version: '2.1'
services:

  #  mysql数据库服务
  pig-mysql:
    build:
      context: ./db      #去db目录下找dockerfile文件
    environment:
      - MYSQL_ROOT_PASSWORD=linux
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    restart: always
    container_name: pig-mysql
    hostname: pig-mysql
    image: pig-mysql
    ports:
      - 3306:3306
    volumes:
      - ./db/my.cnf:/etc/mysql/my.cnf
    ulimits:
      nproc: 65535
      nofile:
        soft: 65536
        hard: 65536
    network_mode: host
    healthcheck:
      test: [ "CMD", "mysql", "-u", "root", "-plinux", "-e", "select count(*) from mc.area_code" ]
      interval: 15s
      timeout: 10s
      retries: 5

  #  redis缓存服务
  pig-redis:
    image: redis:6.0
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    ports:
      - 6379:6379
    command: redis-server --requirepass fsmeeting0229 --appendonly yes
    restart: always
    container_name: pig-redis
    hostname: pig-redis
    network_mode: host
    healthcheck:
      test: [ "CMD", "redis-cli","-a","fsmeeting0229","ping" ]
      interval: 5s
      timeout: 5s
      retries: 10

  #  rabbitmq队列服务
  mc-rabbitmq:
    image: rabbitmq:3.8.3-management
    container_name: mc-rabbitmq
    restart: always
    hostname: mc-myRabbitmq
    ports:
      - 15672:15672
      - 5672:5672
    volumes:
      - ./data:/var/lib/rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=developer
      - RABBITMQ_DEFAULT_PASS=hsteduteam
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    network_mode: host
    healthcheck:
      test: [ "CMD", "rabbitmq-diagnostics","-q" ,"ping" ]
      interval: 30s
      timeout: 10s
      retries: 5


  #  注册中心Nacos服务
  pig-register:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
      - MYSQL_HOST=pig-mysql
      - MYSQL_PORT=3306
      - MYSQL-USER=root
      - MYSQL-PWD=linux
    build:
      context: ./pig-register
    restart: always
    ports:
      - 8848:8848
    container_name: pig-register
    hostname: pig-register
    image: pig-register
    network_mode: host
    depends_on:
      pig-mysql:
        condition: service_healthy
      pig-redis:
        condition: service_healthy
      mc-rabbitmq:
        condition: service_healthy
    healthcheck:
      test: "/bin/netstat -anp | grep 8848"
      interval: 10s
      timeout: 10s
      retries: 10


  #  网关服务
  pig-gateway:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./pig-gateway
    restart: always
    ports:
      - 9999:9999
    container_name: pig-gateway
    hostname: pig-gateway
    image: pig-gateway
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy

  #  认证服务
  pig-auth:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./pig-auth
    restart: always
    container_name: pig-auth
    hostname: pig-auth
    image: pig-auth
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy


  #  监控服务
  pig-monitor:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./pig-visual/pig-monitor
    restart: always
    ports:
      - 5001:5001
    container_name: pig-monitor
    hostname: pig-monitor
    image: pig-monitor
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy

  #  流控服务
  pig-sentinel:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./pig-visual/pig-sentinel-dashboard
    restart: always
    image: pig-sentinel
    container_name: pig-sentinel
    ports:
      - 5003:5003
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy

  #  分布式调度中心服务
  pig-job:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
      - MYSQL_HOST=pig-mysql
      - MYSQL_PORT=3306
      - MYSQL-USER=root
      - MYSQL-PWD=linux
    build:
      context: ./pig-visual/pig-xxl-job-admin
    restart: always
    container_name: pig-job
    hostname: pig-job
    image: pig-job
    ports:
      - 5004:5004
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
    healthcheck:
      test: "/bin/netstat -anp | grep 5004"
      interval: 30s
      timeout: 10s
      retries: 10

  #  组织用户基础服务
  pig-upms-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./pig-upms/pig-upms-biz
    restart: always
    container_name: pig-upms-biz
    hostname: pig-upms-biz
    image: pig-upms-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy


  #  paas对接服务
  mc-competence-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-inner-conn/mc-competence/mc-competence-biz
    restart: always
    container_name: mc-competence-biz
    hostname: mc-competence-biz
    image: mc-competence-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  会议对接服务
  mc-conference-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-inner-conn/mc-conference/mc-conference-biz
    restart: always
    container_name: mc-conference-biz
    hostname: mc-conference-biz
    image: mc-conference-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  终端服务
  mc-terminal-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-inner-conn/mc-terminal/mc-terminal-biz
    restart: always
    container_name: mc-terminal-biz
    hostname: mc-terminal-biz
    image: mc-terminal-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  标签服务
  mc-label-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-res-center/mc-label/mc-label-biz
    restart: always
    container_name: mc-label-biz
    hostname: mc-label-biz
    image: mc-label-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  课程资源中心服务
  mc-rescenter-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-res-center/mc-rescenter-biz
    restart: always
    container_name: mc-rescenter-biz
    hostname: mc-rescenter-biz
    image: mc-rescenter-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  文件系统
  mc-file-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-file/mc-file-biz
    restart: always
    container_name: mc-file-biz
    hostname: mc-file-biz
    image: mc-file-biz
    volumes:
      - /fsmeeting/mc-file/Resource:/Resource
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

  #  教研服务
  mc-research-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-edu/mc-research/mc-research-biz
    restart: always
    container_name: mc-research-biz
    hostname: mc-research-biz
    image: mc-research-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy


  #  首页门户服务
  mc-cms-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-edu/mc-cms/mc-cms-biz
    restart: always
    container_name: mc-cms-biz
    hostname: mc-cms-biz
    image: mc-cms-biz
    ports:
      - 6001:6001
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy


  #  第三方认证服务
  mc-auth-third-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-auth-third/mc-auth-third-biz
    restart: always
    container_name: mc-auth-third-biz
    hostname: mc-auth-third-biz
    image: mc-auth-third-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy


  #  云南1.0标准服务
  mc-yn-standard-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-out-tran/mc-yn-standard/mc-yn-standard-biz
    restart: always
    container_name: mc-yn-standard-biz
    hostname: mc-yn-standard-biz
    image: mc-yn-standard-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy


#  #开发者代码生成服务
#  pig-codegen:
#    environment:
#      - TZ=Asia/Shanghai
#      - LANG=C.UTF-8
#    build:
#      context: ./pig-visual/pig-codegen
#    restart: always
#    container_name: pig-codegen
#    hostname: pig-codegen
#    image: pig-codegen
#    network_mode: host

#  #ftp服务
#  mc-vsftpd:
#    image: fauria/vsftpd:latest
#    container_name: mc-vsftpd
#    hostname: mc-vsftpd
#    restart: always
#    volumes:
#      - /Resource/ftp:/home/vsftpd
#    ports:
#      - "5020:20"
#      - "5021:21"
#      - "21000-21210:21000-21210"
#    environment:
#      - FTP_USER=mc_ftp
#      - FTP_PASS=MC_ftp160422
#      - PASV_ENABLE=YES
#      - pasv_min_port=21000
#      - pasv_max_port=21210
#      - local_max_rate=200000
#      - pasv_promiscuous=YES # 此选项激活时,将关闭PASV模式的安全检查。该检查确保数据连接和控制连接是来自同一个IP地址。小心打开此选项。此选项唯一合理的用法是存在于由安全隧道方案构成的组织中。默认值为NO。
#      - LOG_STDOUT=YES # Any string to enable, empty string or not defined to disable.
#      - PASV_ADDRESS=47.106.103.68 # if you don't specify an IP address to be used in passive mode, the routed IP address of the Docker host will be used. Bear in mind that this could be a local address.
#      - PASV_ADDR_RESOLVE=NO # if you want to use a hostname (as opposed to IP address) in the PASV_ADDRESS option
#      - listen_address=192.168.0.21
#    network_mode: host
#    depends_on:
#      pig-register:
#        condition: service_healthy
#      pig-job:
#        condition: service_healthy
#
#  #维者数据同步服务
#  mc-wz-biz:
#    environment:
#      - TZ=Asia/Shanghai
#      - LANG=C.UTF-8
#    build:
#      context: ./mc-out-tran/mc-wz/mc-wz-biz
#    restart: always
#    container_name: mc-wz-biz
#    hostname: mc-wz-biz
#    image: mc-wz-biz
#    network_mode: host
#    depends_on:
#      pig-register:
#        condition: service_healthy
#      pig-job:
#        condition: service_healthy
#
#  #数据迁移模块
#  mc-data-move-biz:
#    environment:
#      - TZ=Asia/Shanghai
#      - LANG=C.UTF-8
#    build:
#      context: ./mc-out-tran/mc-data-move/mc-data-move-biz
#    restart: always
#    container_name: mc-data-move-biz
#    hostname: mc-data-move-biz
#    image: mc-data-move-biz
#    network_mode: host
#    depends_on:
#      pig-register:
#        condition: service_healthy
#      pig-job:
#        condition: service_healthy


  #  websocket互动和推送服务模块
  mc-websocket-biz:
    environment:
      - TZ=Asia/Shanghai
      - LANG=C.UTF-8
    build:
      context: ./mc-inner-conn/mc-websocket/mc-websocket-biz
    restart: always
    container_name: mc-websocket-biz
    hostname: mc-websocket-biz
    image: mc-websocket-biz
    network_mode: host
    depends_on:
      pig-register:
        condition: service_healthy
      pig-job:
        condition: service_healthy

这里父工程的docker文件相当于把其他子工程中有dockerfile文件打包的全部包含进来,执行更新的时候docker-compose up -d可以将每个子工程的打包的镜像全部更新。

3.db模块分析

里面放的都是数据库脚本,基础脚本以及增量脚本。
dockerfile:

FROM mysql:5.7.34
CMD [ "--max_connections=2000" ]
MAINTAINER lengleng(wangiegie@gmail.com)

#下面两句是docker服务器和宿主机时间同步操作
ENV TZ=Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#  缺省状态下只会将目录下的文件拷贝过去,如果连同目录一起拷贝则需要在目标中指定目录名称
COPY ./6.0.1 /docker-entrypoint-initdb.d/
COPY ./6.1.1 /docker-entrypoint-initdb.d/
COPY ./6.1.2 /docker-entrypoint-initdb.d/
COPY ./6.2.0 /docker-entrypoint-initdb.d/
COPY ./xdf /docker-entrypoint-initdb.d/

my.cnf:

[mysql]
default-character-set=utf8

[mysqld]
max_connections=2000
4.mc-auth-third模块分析

pom.xml:



	
		pig
		com.pig4cloud
		3.1.1
	
	4.0.0

	mc-auth-third
    pom
    
        mc-auth-third-biz
		mc-auth-third-api
	

    
		8
		8
	



RemoteAuthThirdService:

package com.hst.mc.third.api.feign;

import com.hst.mc.third.api.feign.factory.RemoteAuthThirdServiceFallbackFactory;
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import com.pig4cloud.pig.common.core.constant.ServiceNameConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(
    contextId = "remoteAuthThirdService",
    value = ServiceNameConstants.AUTH_THIRD_SERVICE,    #指定被调用的模块名
    fallbackFactory = RemoteAuthThirdServiceFallbackFactory.class,
    path = "/oauth")
public interface RemoteAuthThirdService {

    
    @GetMapping(value = "/getThirdUniqueString/{type}")
    String getThirdUniqueString(@PathVariable(value = "type") String type,
                                @RequestParam("accessCode") String accessCode,
                                @RequestHeader(SecurityConstants.FROM) String from);

}

RemoteAuthThirdServiceFallbackImpl:

package com.hst.mc.third.api.feign.fallback;

import cn.hutool.core.util.StrUtil;
import com.hst.mc.third.api.feign.RemoteAuthThirdService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class RemoteAuthThirdServiceFallbackImpl implements RemoteAuthThirdService {

    @Setter
    private Throwable cause;


    @Override
    public String getThirdUniqueString(String type, String accessCode, String from) {
        log.error("获取第三方唯一值失败", cause);
        return StrUtil.EMPTY;
    }
}

RemoteAuthThirdServiceFallbackFactory:


package com.hst.mc.third.api.feign.factory;

import com.hst.mc.third.api.feign.RemoteAuthThirdService;
import com.hst.mc.third.api.feign.fallback.RemoteAuthThirdServiceFallbackImpl;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class RemoteAuthThirdServiceFallbackFactory implements FallbackFactory {

    @Override
    public RemoteAuthThirdService create(Throwable throwable) {
        RemoteAuthThirdServiceFallbackImpl remoteAuthThirdServiceFallback = new RemoteAuthThirdServiceFallbackImpl();
        remoteAuthThirdServiceFallback.setCause(throwable);
        return remoteAuthThirdServiceFallback;
    }

}

熔断工厂学习

mc-auth-third-biz是oauth2的配置相关等。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/770163.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号