Donkey框架之一:概述

百聯達發表於2017-07-11
一:背景

J2EE框架越來越成熟,避不開的Spring體系,國內很多人都在用的dubbo,還有隨著Docker,K8S發展起來的微服務框架,容器框架。 在工作過程中,一直想著基於Spring體系封裝一個適合自己開發團

隊的框架,封裝一些成熟的元件,同時又暴露一些內容(避免過度封裝,導致開發人員只是會用,而無法瞭解其實現原理)。構建的過程中,不知不覺竟然成了一個毛坯版的Spring Boot,不能不感

慨Spring的與時俱進,急人之所急。


二:簡介

這個架構有Maven構建,暫時分為一下幾個模組,每個模組都獨立封裝成jar包,可在專案中引用

1.donkey-common-utils-support   工具類模組

2.donkey-common-dao-support   資料訪問類模組 類似於Spring-Data-Jpa

3.donkey-common-service-support 業務處理層模組

4.donkey-common-controller-support 控制層處理模組

5.donkey-common-cache-support 快取層處理模組

6.donkey-common-jms-support 訊息中介軟體層處理模組

7.donkey-common-session-support  session集中處理模組

8.donkey-common-web-support web集中處理模組

9.donkey-common-security-web-support web安裝機制處理模組

10.donkey-mvc-api-demo  毛坯版的Spring boot 示例

11.donkey-spring-boot-web-demo 如何基於框架使用Spring boot 示例



三:框架的POM.xml檔案


點選(此處)摺疊或開啟

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="" xmlns:xsi=""
  3.     xsi:schemaLocation=" ">
  4.     <modelVersion>4.0.0</modelVersion>

  5.     <groupId>com.brilliantstar</groupId>
  6.     <artifactId>donkey</artifactId>
  7.     <version>0.0.1-SNAPSHOT</version>
  8.     <packaging>pom</packaging>
  9.     <name>donkey parent</name>
  10.     <description>The parent project of donkey</description>

  11.     <repositories>
  12.         <repository>
  13.             <id>nexus</id>
  14.             <name>BrilliantStar Nexus Repository</name>
  15.             <url>http://121.42.157.168:8081/nexus/content/groups/public</url>
  16.         </repository>
  17.     </repositories>

  18.     <!-- 模組 -->
  19.     <modules>
  20.         <module>donkey-common-utils-support</module>
  21.         <module>donkey-common-dao-support</module>
  22.         <module>donkey-common-service-support</module>
  23.         <module>donkey-common-controller-support</module>
  24.         <module>donkey-mvc-api-demo</module>
  25.         <module>donkey-common-cache-support</module>
  26.         <module>donkey-common-web-support</module>
  27.         <module>donkey-common-security-web-support</module>
  28.         <module>donkey-common-session-support</module>
  29.         <module>donkey-common-jms-support</module>
  30.         <module>donkey-spring-boot-web-demo</module>
  31.     </modules>

  32.     <!-- 屬性 -->
  33.     <properties>
  34.         <spring.version>4.3.9.RELEASE</spring.version>
  35.         <commons-lang3.version>3.6</commons-lang3.version>
  36.         <commons-lang.version>2.5</commons-lang.version>
  37.         <commons.io.version>2.5</commons.io.version>
  38.         <commons.logging.version>1.2</commons.logging.version>
  39.         <jackson.json.version>1.9.13</jackson.json.version>
  40.         <jackson.fasterxml.version>2.6.0</jackson.fasterxml.version>
  41.         <log4j2.version>2.7</log4j2.version>
  42.         <gson.version>2.2.4</gson.version>
  43.         <poi.version>3.9</poi.version>
  44.         <jsonlib.version>2.4</jsonlib.version>
  45.         <bouncycastle.version>140</bouncycastle.version>
  46.         <javax.persistence.version>1.0.2</javax.persistence.version>
  47.         <junit.version>4.10</junit.version>
  48.         <servlet.api.version>3.1.0</servlet.api.version>
  49.         <c3p0.version>0.9.1</c3p0.version>
  50.         <mysql.connector.version>5.1.36</mysql.connector.version>

  51.         <aspectj.version>1.8.10</aspectj.version>
  52.         <atomikos.version>4.0.4</atomikos.version>
  53.         <atomikos.transactions.jdbc.version>3.8.0</atomikos.transactions.jdbc.version>
  54.         <jta.version>1.1</jta.version>
  55.         <spring.data.redis.version>1.8.4.RELEASE</spring.data.redis.version>
  56.         <jedis.version>2.9.0</jedis.version>
  57.         <thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>
  58.         <spring.session.redis.version>1.3.1.RELEASE</spring.session.redis.version>
  59.         <spring-security.version>4.2.3.RELEASE</spring-security.version>
  60.         <jsr250.version>1.0</jsr250.version>
  61.         <activemq.version>5.14.5</activemq.version>
  62.         <javax.jms.version>1.1-rev-1</javax.jms.version>
  63.         <slf4j.version>1.7.25</slf4j.version>
  64.         <springframework.boot.version>1.5.4.RELEASE</springframework.boot.version>
  65.         <tomcat.version>8.5.15</tomcat.version>
  66.         <thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
  67.         <spring-hateoas.version>0.23.0.RELEASE</spring-hateoas.version>
  68.     </properties>

  69.     <!-- 依賴配置 -->
  70.     <dependencyManagement>
  71.         <dependencies>

  72.             <dependency>
  73.                 <groupId>org.springframework.hateoas</groupId>
  74.                 <artifactId>spring-hateoas</artifactId>
  75.                 <version>${spring-hateoas.version}</version>
  76.             </dependency>

  77.             <dependency>
  78.                 <groupId>org.springframework.boot</groupId>
  79.                 <artifactId>spring-boot-starter-thymeleaf</artifactId>
  80.                 <version>${springframework.boot.version}</version>
  81.             </dependency>

  82.             <dependency>
  83.                 <groupId>nz.net.ultraq.thymeleaf</groupId>
  84.                 <artifactId>thymeleaf-layout-dialect</artifactId>
  85.                 <version>${thymeleaf-layout-dialect.version}</version>
  86.             </dependency>


  87.             <dependency>
  88.                 <groupId>org.springframework.boot</groupId>
  89.                 <artifactId>spring-boot-starter-web</artifactId>
  90.                 <version>${springframework.boot.version}</version>
  91.             </dependency>

  92.             <dependency>
  93.                 <groupId>org.springframework.boot</groupId>
  94.                 <artifactId>spring-boot-starter-actuator</artifactId>
  95.                 <version>${springframework.boot.version}</version>
  96.             </dependency>

  97.             <dependency>
  98.                 <groupId>org.springframework.boot</groupId>
  99.                 <artifactId>spring-boot-starter-websocket</artifactId>
  100.                 <version>${springframework.boot.version}</version>
  101.             </dependency>

  102.             <dependency>
  103.                 <groupId>org.springframework.boot</groupId>
  104.                 <artifactId>spring-boot-starter-test</artifactId>
  105.                 <version>${springframework.boot.version}</version>
  106.                 <scope>test</scope>
  107.             </dependency>

  108.             <dependency>
  109.                 <groupId>org.springframework.boot</groupId>
  110.                 <artifactId>spring-boot-starter-tomcat</artifactId>
  111.                 <version>${springframework.boot.version}</version>
  112.                 <scope>provided</scope>
  113.             </dependency>


  114.             <dependency>
  115.                 <groupId>org.springframework.boot</groupId>
  116.                 <artifactId>spring-boot-starter-log4j2</artifactId>
  117.                 <version>${springframework.boot.version}</version>
  118.             </dependency>

  119.             <dependency>
  120.                 <groupId>org.slf4j</groupId>
  121.                 <artifactId>slf4j-api</artifactId>
  122.                 <version>${slf4j.version}</version>
  123.             </dependency>

  124.             <dependency>
  125.                 <groupId>commons-logging</groupId>
  126.                 <artifactId>commons-logging</artifactId>
  127.                 <version>${commons.logging.version}</version>
  128.             </dependency>

  129.             <dependency>
  130.                 <groupId>org.springframework</groupId>
  131.                 <artifactId>spring-core</artifactId>
  132.                 <version>${spring.version}</version>
  133.             </dependency>

  134.             <dependency>
  135.                 <groupId>org.springframework</groupId>
  136.                 <artifactId>spring-beans</artifactId>
  137.                 <version>${spring.version}</version>
  138.             </dependency>

  139.             <dependency>
  140.                 <groupId>org.springframework</groupId>
  141.                 <artifactId>spring-jdbc</artifactId>
  142.                 <version>${spring.version}</version>
  143.             </dependency>

  144.             <dependency>
  145.                 <groupId>org.springframework</groupId>
  146.                 <artifactId>spring-web</artifactId>
  147.                 <version>${spring.version}</version>
  148.             </dependency>

  149.             <dependency>
  150.                 <groupId>org.springframework</groupId>
  151.                 <artifactId>spring-webmvc</artifactId>
  152.                 <version>${spring.version}</version>
  153.             </dependency>

  154.             <dependency>
  155.                 <groupId>org.springframework</groupId>
  156.                 <artifactId>spring-context</artifactId>
  157.                 <version>${spring.version}</version>
  158.             </dependency>

  159.             <dependency>
  160.                 <groupId>org.springframework</groupId>
  161.                 <artifactId>spring-context-support</artifactId>
  162.                 <version>${spring.version}</version>
  163.             </dependency>

  164.             <dependency>
  165.                 <groupId>org.springframework</groupId>
  166.                 <artifactId>spring-aop</artifactId>
  167.                 <version>${spring.version}</version>
  168.             </dependency>

  169.             <dependency>
  170.                 <groupId>org.springframework</groupId>
  171.                 <artifactId>spring-tx</artifactId>
  172.                 <version>${spring.version}</version>
  173.             </dependency>

  174.             <dependency>
  175.                 <groupId>org.springframework.data</groupId>
  176.                 <artifactId>spring-data-redis</artifactId>
  177.                 <version>${spring.data.redis.version}</version>
  178.             </dependency>

  179.             <dependency>
  180.                 <groupId>org.springframework.session</groupId>
  181.                 <artifactId>spring-session-data-redis</artifactId>
  182.                 <version>${spring.session.redis.version}</version>
  183.             </dependency>

  184.             <dependency>
  185.                 <groupId>org.springframework.security</groupId>
  186.                 <artifactId>spring-security-core</artifactId>
  187.                 <version>${spring-security.version}</version>
  188.             </dependency>

  189.             <dependency>
  190.                 <groupId>org.springframework.security</groupId>
  191.                 <artifactId>spring-security-web</artifactId>
  192.                 <version>${spring-security.version}</version>
  193.             </dependency>
  194.             <dependency>
  195.                 <groupId>org.springframework.security</groupId>
  196.                 <artifactId>spring-security-config</artifactId>
  197.                 <version>${spring-security.version}</version>
  198.             </dependency>
  199.             <dependency>
  200.                 <groupId>org.springframework.security</groupId>
  201.                 <artifactId>spring-security-taglibs</artifactId>
  202.                 <version>${spring-security.version}</version>
  203.             </dependency>

  204.             <dependency>
  205.                 <groupId>org.springframework</groupId>
  206.                 <artifactId>spring-jms</artifactId>
  207.                 <version>${spring.version}</version>
  208.             </dependency>

  209.             <dependency>
  210.                 <groupId>org.apache.activemq</groupId>
  211.                 <artifactId>activemq-all</artifactId>
  212.                 <version>${activemq.version}</version>
  213.             </dependency>


  214.             <dependency>
  215.                 <groupId>javax.jms</groupId>
  216.                 <artifactId>jms-api</artifactId>
  217.                 <version>${javax.jms.version}</version>
  218.             </dependency>

  219.             <dependency>
  220.                 <groupId>javax.annotation</groupId>
  221.                 <artifactId>jsr250-api</artifactId>
  222.                 <version>${jsr250.version}</version>
  223.             </dependency>

  224.             <dependency>
  225.                 <groupId>org.apache.logging.log4j</groupId>
  226.                 <artifactId>log4j-api</artifactId>
  227.                 <version>${log4j2.version}</version>
  228.             </dependency>
  229.             <dependency>
  230.                 <groupId>org.apache.logging.log4j</groupId>
  231.                 <artifactId>log4j-core</artifactId>
  232.                 <version>${log4j2.version}</version>
  233.             </dependency>

  234.             <dependency>
  235.                 <groupId>org.apache.logging.log4j</groupId>
  236.                 <artifactId>log4j-slf4j-impl</artifactId>
  237.                 <version>${log4j2.version}</version>
  238.             </dependency>

  239.             <dependency>
  240.                 <groupId>org.apache.logging.log4j</groupId>
  241.                 <artifactId>log4j-web</artifactId>
  242.                 <version>${log4j2.version}</version>
  243.             </dependency>

  244.             <dependency>
  245.                 <groupId>com.google.code.gson</groupId>
  246.                 <artifactId>gson</artifactId>
  247.                 <version>${gson.version}</version>
  248.             </dependency>

  249.             <dependency>
  250.                 <groupId>org.apache.commons</groupId>
  251.                 <artifactId>commons-lang3</artifactId>
  252.                 <version>${commons-lang3.version}</version>
  253.             </dependency>

  254.             <dependency>
  255.                 <groupId>commons-io</groupId>
  256.                 <artifactId>commons-io</artifactId>
  257.                 <version>${commons.io.version}</version>
  258.             </dependency>


  259.             <dependency>
  260.                 <groupId>com.fasterxml.jackson.core</groupId>
  261.                 <artifactId>jackson-core</artifactId>
  262.                 <version>${jackson.fasterxml.version}</version>
  263.             </dependency>

  264.             <dependency>
  265.                 <groupId>com.fasterxml.jackson.core</groupId>
  266.                 <artifactId>jackson-databind</artifactId>
  267.                 <version>${jackson.fasterxml.version}</version>
  268.             </dependency>


  269.             <dependency>
  270.                 <groupId>com.fasterxml.jackson.core</groupId>
  271.                 <artifactId>jackson-annotations</artifactId>
  272.                 <version>${jackson.fasterxml.version}</version>
  273.             </dependency>

  274.             <dependency>
  275.                 <groupId>org.apache.poi</groupId>
  276.                 <artifactId>poi</artifactId>
  277.                 <version>${poi.version}</version>
  278.             </dependency>

  279.             <dependency>
  280.                 <groupId>net.sf.json-lib</groupId>
  281.                 <artifactId>json-lib</artifactId>
  282.                 <version>${jsonlib.version}</version>
  283.                 <classifier>jdk15</classifier>
  284.                 <exclusions>
  285.                     <exclusion>
  286.                         <artifactId>commons-logging</artifactId>
  287.                         <groupId>commons-logging</groupId>
  288.                     </exclusion>
  289.                 </exclusions>
  290.             </dependency>

  291.             <dependency>
  292.                 <groupId>bouncycastle</groupId>
  293.                 <artifactId>bcprov-jdk15</artifactId>
  294.                 <version>${bouncycastle.version}</version>
  295.             </dependency>

  296.             <dependency>
  297.                 <groupId>javax.persistence</groupId>
  298.                 <artifactId>persistence-api</artifactId>
  299.                 <version>${javax.persistence.version}</version>
  300.             </dependency>

  301.             <dependency>
  302.                 <groupId>javax.servlet</groupId>
  303.                 <artifactId>javax.servlet-api</artifactId>
  304.                 <version>${servlet.api.version}</version>
  305.                 <scope>provided</scope>
  306.             </dependency>

  307.             <dependency>
  308.                 <groupId>c3p0</groupId>
  309.                 <artifactId>c3p0</artifactId>
  310.                 <version>${c3p0.version}</version>
  311.             </dependency>

  312.             <dependency>
  313.                 <groupId>mysql</groupId>
  314.                 <artifactId>mysql-connector-java</artifactId>
  315.                 <version>${mysql.connector.version}</version>
  316.             </dependency>

  317.             <dependency>
  318.                 <groupId>org.aspectj</groupId>
  319.                 <artifactId>aspectjrt</artifactId>
  320.                 <version>${aspectj.version}</version>
  321.             </dependency>

  322.             <dependency>
  323.                 <groupId>org.aspectj</groupId>
  324.                 <artifactId>aspectjweaver</artifactId>
  325.                 <version>${aspectj.version}</version>
  326.             </dependency>


  327.             <dependency>
  328.                 <groupId>com.atomikos</groupId>
  329.                 <artifactId>transactions</artifactId>
  330.                 <version>${atomikos.version}</version>
  331.             </dependency>
  332.             <dependency>
  333.                 <groupId>com.atomikos</groupId>
  334.                 <artifactId>transactions-api</artifactId>
  335.                 <version>${atomikos.version}</version>
  336.             </dependency>
  337.             <dependency>
  338.                 <groupId>com.atomikos</groupId>
  339.                 <artifactId>atomikos-util</artifactId>
  340.                 <version>${atomikos.version}</version>
  341.             </dependency>
  342.             <dependency>
  343.                 <groupId>com.atomikos</groupId>
  344.                 <artifactId>transactions-jdbc-deprecated</artifactId>
  345.                 <version>${atomikos.transactions.jdbc.version}</version>
  346.             </dependency>
  347.             <dependency>
  348.                 <groupId>com.atomikos</groupId>
  349.                 <artifactId>transactions-jta</artifactId>
  350.                 <version>${atomikos.version}</version>
  351.             </dependency>
  352.             <dependency>
  353.                 <groupId>com.atomikos</groupId>
  354.                 <artifactId>transactions-jdbc</artifactId>
  355.                 <version>${atomikos.version}</version>
  356.             </dependency>

  357.             <dependency>
  358.                 <groupId>javax.transaction</groupId>
  359.                 <artifactId>jta</artifactId>
  360.                 <version>${jta.version}</version>
  361.             </dependency>

  362.             <dependency>
  363.                 <groupId>redis.clients</groupId>
  364.                 <artifactId>jedis</artifactId>
  365.                 <version>${jedis.version}</version>
  366.             </dependency>

  367.             <dependency>
  368.                 <groupId>org.thymeleaf</groupId>
  369.                 <artifactId>thymeleaf-spring4</artifactId>
  370.                 <version>${thymeleaf.version}</version>
  371.             </dependency>

  372.             <dependency>
  373.                 <groupId>junit</groupId>
  374.                 <artifactId>junit</artifactId>
  375.                 <version>${junit.version}</version>
  376.                 <scope>test</scope>
  377.             </dependency>
  378.         </dependencies>
  379.     </dependencyManagement>

  380.     <!-- 外掛配置 -->
  381.     <build>
  382.         <pluginManagement>
  383.             <plugins>
  384.                 <plugin>
  385.                     <groupId>org.apache.maven.plugins</groupId>
  386.                     <artifactId>maven-compiler-plugin</artifactId>
  387.                     <configuration>
  388.                         <source>1.8</source>
  389.                         <target>1.8</target>
  390.                         <compilerArguments>
  391.                             <extdirs>${java.home}/lib</extdirs>
  392.                             <bootclasspath>${java.home}/jre/lib/rt.jar;${java.home}/jre/lib/jce.jar</bootclasspath>
  393.                         </compilerArguments>
  394.                     </configuration>
  395.                 </plugin>

  396.                 <plugin>
  397.                     <groupId>org.apache.maven.plugins</groupId>
  398.                     <artifactId>maven-resources-plugin</artifactId>
  399.                     <configuration>
  400.                         <encoding>UTF-8</encoding>
  401.                     </configuration>
  402.                 </plugin>
  403.             </plugins>
  404.         </pluginManagement>
  405.     </build>
  406. </project>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28624388/viewspace-2141907/,如需轉載,請註明出處,否則將追究法律責任。

相關文章