Spring study notes-build a springboot framework by hand

1. Create a project

1. Create a project

1. Open Intellij, create a new Project, select the Maven project, fill in the name, and finish directly to create it. For example, the name of the project I created is learn_framework

The original directory is as follows:

 

2. Increase module

New Model is added on the right side of the project. For example, if the Model name is client, the module will be automatically updated in the parent pom file, as shown below

 

2. Configuration file

1.pom

Configure dependencies in the parent pom, the example is as follows, if you need to add other dependencies, you can go to the maven official website to search

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>2.4.0-M2</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.68.noneautotype</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <version>2.4.0-M4</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>2.1.2.RELEASE</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

For example, if we configure the module here, we also need to configure the pom file in the module, and we can choose to inherit the parent pom file, such as

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

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

 

2. Configure application.properties, which is configured in the module where the startup class is located

Add application.properties under the resource file, and set the database information or other information in it

spring.datasource.url=jdbc:oracle:thin:@xx.xx.com:1557:xx
spring.datasource.username=xx
spring.datasource.password=xx
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver


A simple framework is built, let’s start writing code

 

3. Write code

The following is omitted.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/mumuwang1234/article/details/110311896