Springboot integrates Dubbo 3 X scaffold

Time:2022-1-21

Article introduction:
1. Introduce the version dependency of the article content
2. Create springboot foundation project
3. Modify the configuration file of basic engineering
4. Add dependency package management for Dubbo 3
5. Create sub project demonstration
6. Modify POM profiles for parent and child projects
7. Add log file and default port number

1. Dependent version

rely on edition
Springboot 2.5.x
dubbo 3.X

2. Create springboot foundation project

Springboot integrates Dubbo 3 X scaffold

Create a basic demonstration project
Springboot integrates Dubbo 3 X scaffold

Choose a quick build for springboot
Springboot integrates Dubbo 3 X scaffold

The basic elements of Maven can be filled in according to your own habits
Springboot integrates Dubbo 3 X scaffold

Dependent package introduction

Since we adopt the form of BOM, the parent project does not need to introduce any dependencies for the time being

Springboot integrates Dubbo 3 X scaffold

Physical location of project storage

The computers for preparing and lecturing may be different, so the physical location may not be this when lecturing, ha ha~

Springboot integrates Dubbo 3 X scaffold

Delete files not related to the course

3. Modify profile

The original configuration file is as follows:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jiangzh.course</groupId>
    <artifactId>dubbo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>dubbo_3_study</name>
    <description>dubbo_ 3 learn < / description >
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Modified configuration file: [the modified contents are summarized with notes, and you can directly find the location with notes]

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jiangzh.course</groupId>
    <!--  Modify a higher artifactid -- >
    <artifactId>dubbo-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!--  Add packaging type -- >
    <packaging>pom</packaging>

    <name>dubbo_3_study</name>
    <description>dubbo_ 3 learn < / description >
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <!--  The parent project does not import dependent packages, which will affect the child project -- >
    <!--
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    -->

    <!--  The parent project manages dependent packages -- >
    <dependencyManagement>
        <dependencies>

        </dependencies>
    </dependencyManagement>

    <!--  Remove the packaging management of springboot and handle it separately in the sub project -- >
    <!--
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    -->
    
</project>

4. Add dependency package management for Dubbo 3

1. In POM Add the version number configuration of Dubbo to the properties in XML

<properties>
    <java.version>1.8</java.version>
    <!--  Add Dubbo version number control -- >
    <dubbo.version>3.0.0.preview</dubbo.version>
</properties>

2. In POM Add dependency management related dependency management in XML

<!--  The parent project manages dependent packages -- >
    <dependencyManagement>
        <dependencies>
            <!--  Add Dubbo dependency package management -- >
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo</artifactId>
                <version>${dubbo.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-dependencies-zookeeper</artifactId>
                <version>${dubbo.version}</version>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>3.7.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-framework</artifactId>
                <version>5.1.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-recipes</artifactId>
                <version>5.1.0</version>
            </dependency>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-all</artifactId>
                <version>4.1.65.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

5. Example of establishing sub project

Springboot integrates Dubbo 3 X scaffold

Create sub module

Repeat the steps when creating the parent project

Springboot integrates Dubbo 3 X scaffold

Select springboot quick launch
Springboot integrates Dubbo 3 X scaffold

Set Maven coordinates
Springboot integrates Dubbo 3 X scaffold

We still don’t choose anything. In the later stage, we add the dependency package ourselves
Springboot integrates Dubbo 3 X scaffold

Select storage location
Springboot integrates Dubbo 3 X scaffold

Delete unwanted content
Springboot integrates Dubbo 3 X scaffold

Modify profile format

6. Modify POM profiles for parent and child projects

6.1 modify POM configuration file of subproject

Profile location:

Springboot integrates Dubbo 3 X scaffold

POM profile of subproject

Before modification:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jiangzh.course</groupId>
    <artifactId>dubbo-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>dubbo-demo</name>
    < description > demo sub project creation < / description >
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

After modification: [the modified contents are summarized with notes, and you can directly find the location with notes]

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <!--  Modify the parent project dependency of springboot to its own parent project, so that you can inherit the springboot dependency -- > in the parent project
        <groupId>com.jiangzh.course</groupId>
        <artifactId>dubbo-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <groupId>com.jiangzh.course</groupId>
    <artifactId>dubbo-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>dubbo-demo</name>
    < description > demo sub project creation < / description >
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

6.2 modify POM configuration file of parent project

Springboot integrates Dubbo 3 X scaffold

Add module management

7. Add log file and default port number

Springboot integrates Dubbo 3 X scaffold

Add basic configuration
server:
  port: 8080
  

logging:
  config: classpath:logback.xml

7.1 add log configuration

Springboot integrates Dubbo 3 X scaffold

Add profile

Profile content:

<configuration>
    <appender name="STDOUT">
        <encoder>
            <pattern>%highlight(%-5level) (%file:%line\)- %m%n</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

Recommended Today

2021-11-09 volcano map based on RNA SEQ table (second time)

setwd(“C:\\Users\\Administrator.DESKTOP-4UQ3Q0K\\Desktop”) library(“readxl”) data <- read_excel(“RNA-seq.xlsx”) library(dplyr) library(ggplot2) library(ggrepel) data #Convert to tibble for subsequent use and remove unnecessary columns; Data < – Data [C (- 10, – 11, – 14, – 15, – 16, – 19, – 20, – 21, – 22)] # don’t try #data <- as_tibble(data[c(-10,-11,-14,-15,-16,-19,-20,-21,-22)]) data$padj<-as.numeric(as.matrix(data$padj)) #Take logarithm of Q value; data$log10FDR […]