更新 Leaf starter

一、Leaf starter更新

1.常用生成ID的工具
  1. 数据主键自增
  2. UUID
  3. 百度分布式ID生成器: uid-generator
  4. 美团分布式ID生成器: Leaf & 文档
2. Leaf升级版本
  1. 下载源码 feature/spring-boot-starter 分支
git clone -b feature/spring-boot-starter --single-branch https://github.com/Meituan-Dianping/Leaf.git

在这里插入图片描述

  1. 打开leaf-parent 的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.sankuai.inf.leaf</groupId>
    <artifactId>leaf-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0.2-RELEASE</version>
    <name>Leaf</name>

    <modules>
        <module>leaf-core</module>
        <module>leaf-server</module>
        <module>leaf-plugin</module>
    </modules>
    <description>Distributed ID Generate Service</description>
    <developers>
        <developer>
            <id>zhangzhitong</id>
            <name>zhangzhitong</name>
            <email>zhitongzhang@outlook.com</email>
        </developer>
        <developer>
            <id>zhanghan</id>
            <name>zhanghan</name>
            <email>han122655904@163.com</email>
        </developer>
        <developer>
            <id>xiezhaodong</id>
            <name>xiezhaodong</name>
            <email>pursuer_xie@foxmail.com</email>
        </developer>
        <developer>
            <id>chenzenglin</id>
            <name>chenzenglin</name>
            <email>chsengni@163.com</email>
        </developer>
    </developers>
    <organization>
        <name>Meituan-Dianping Group</name>
        <url>https://github.com/Meituan-Dianping</url>
    </organization>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <junit.version>4.13.2</junit.version>
        <spring.version>5.3.14</spring.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <mybatis.version>3.5.7</mybatis.version>
        <perf4j.version>0.9.16</perf4j.version>
        <curator.version>5.2.0</curator.version>
        <slf4j.version>1.7.32</slf4j.version>
        <druid.version>1.2.8</druid.version>
        <jackson-databind.version>2.13.1</jackson-databind.version>
        <mysql-connector-java.version>8.0.27</mysql-connector-java.version>
        <commons-io.version>2.11.0</commons-io.version>
        <log4j.version>2.14.1</log4j.version>
        <mybatis-spring.version>2.0.6</mybatis-spring.version>
        <spring-boot.version>2.6.2</spring-boot.version>
        <leaf.version>1.0.2-RELEASE</leaf.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--leaf版本一致-->
            <dependency>
                <groupId>com.sankuai.inf.leaf</groupId>
                <artifactId>leaf-core</artifactId>
                <version>${leaf.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sankuai.inf.leaf</groupId>
                <artifactId>leaf-boot-starter</artifactId>
                <version>${leaf.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sankuai.inf.leaf</groupId>
                <artifactId>leaf-plugin</artifactId>
                <version>${leaf.version}</version>
            </dependency>
             <dependency>
                <groupId>com.sankuai.inf.leaf</groupId>
                <artifactId>leaf-server</artifactId>
                <version>${leaf.version}</version>
            </dependency>
             <!--leaf版本一致-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>${druid.version}</version>
            </dependency>
            <!--zk-->
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-recipes</artifactId>
                <version>${curator.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>log4j</artifactId>
                        <groupId>log4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>

            <dependency>
                <groupId>org.perf4j</groupId>
                <artifactId>perf4j</artifactId>
                <version>${perf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</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-context</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot</artifactId>
                <version>${spring-boot.version}</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${mysql-connector-java.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>${mybatis-spring.version}</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <distributionManagement>
        <repository>
            <id>rdc-releases</id>
            <url>https://repo.rdc.aliyun.com/repository/30278-release-hOamJV/</url>
        </repository>
        <snapshotRepository>
            <id>rdc-snapshots</id>
            <url>https://repo.rdc.aliyun.com/repository/30278-snapshot-k5cEXE/</url>
        </snapshotRepository>
    </distributionManagement>
    <build>
        <finalName>leaf</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.5.201505241946</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>
                                ${project.build.directory}/${project.artifactId}-jacoco.exec
                            </destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>
                                ${project.build.directory}/${project.artifactId}-jacoco.exec
                            </dataFile>
                            <outputDirectory>${project.build.directory}/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.3</version>
            </plugin>
        </plugins>
    </build>
</project>
  1. 打开leaf-core的pom.xml 粘贴下面内容

在这里插入图片描述

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.sankuai.inf.leaf</groupId>
        <artifactId>leaf-parent</artifactId>
        <version>1.0.2-RELEASE</version>
    </parent>
    <artifactId>leaf-core</artifactId>

    <name>leaf-core</name>
    
    <dependencies>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.perf4j</groupId>
            <artifactId>perf4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!--zk-->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- test scope -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.0.1-jre</version>
	    </dependency>
    </dependencies>
</project>
  1. 打开leaf-plugin 的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">
    <parent>
        <artifactId>leaf-parent</artifactId>
        <groupId>com.sankuai.inf.leaf</groupId>
        <version>1.0.2-RELEASE</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>leaf-plugin</artifactId>
    <packaging>pom</packaging>
    <modules>
        <module>leaf-boot-starter</module>
    </modules>
    <dependencies>
        <!--实现自动化配置-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
    </dependencies>
</project>
  1. 打开leaf-boot-starter 的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">
    <parent>
        <artifactId>leaf-plugin</artifactId>
        <groupId>com.sankuai.inf.leaf</groupId>
        <version>1.0.2-RELEASE</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>leaf-boot-starter</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.sankuai.inf.leaf</groupId>
            <artifactId>leaf-core</artifactId>
            <version>${leaf.version}</version>
        </dependency>
    </dependencies>
</project>
  1. 打开leaf-server 的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>
    <parent>
        <groupId>com.sankuai.inf.leaf</groupId>
        <artifactId>leaf-parent</artifactId>
        <version>1.0.2-RELEASE</version>
    </parent>
    <artifactId>leaf-server</artifactId>
    <packaging>jar</packaging>
    <name>leaf-server</name>
    <description>Leaf HTTP Server</description>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Spring Boot Freemarker 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sankuai.inf.leaf</groupId>
            <artifactId>leaf-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
        </dependency>
        <!--zk-->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.sankuai.inf.leaf.server.LeafServerApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <!-- 表示复制的jar文件去掉版本信息 -->
                            <stripVersion>false</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
  1. 安装到本地
mvn clean install -Dmaven.test.skip=true 

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
升级完成

框架版本
Leaf1.0.2-RELEASE
Spring Framework5.3.14
Spring Boot2.6.2
MySQL Driver8.0.27
Logo

鸿蒙生态一站式服务平台。

更多推荐