[Springboot development monomers web shop] 1. Introduction to the building and environment

Introduction to the environment and to build

Brief

springboot itself in order to make use of the services, why we have to look at its opposite use it to develop a single web application do?
In the reality of our development work, a lot of business systems using a single application, especially for small and medium sized team, select the service of development in the beginning of the development project is worth the wait, because for such a team, bound All the work is done we need developers to do, such as:

  • Technology Selection
  • Business requirements analysis
  • Business demand for design
  • Extensive testing
  • Run deployment
  • Operational health monitoring
  • ...

If small companies or small team developers to focus on large-scale work in addition to the business, then our development efficiency is bound to be particularly low, such as the development of a version of our system come out, maybe this need is not so in line with current the development of such a team in pursuit of fast track and facilitate the deployment of updates. Someone will ask, why do not we choose SpringMVCit? Of course, if the team itself has formed a framework can be used to SpringMVC ready to use, of course, is completely ok, but all used Springboot students know.

  1. Springboot help us in SpringMVC previously required the use of XML to configure the configuration of the built-in, developers can put a lot of focus on business optimization study above without the need to focus on how it is configured.
  2. As for technology selection, we must think of our business may be rapid expansion in the late we have to be able to quickly update the technical system or upgrade the system, then the instinct of springboot of service can be manifested.
  3. Many of the new students in learning springboot of too much information itself is a demo of the study, further research is needed to apply their knowledge after all, not too close to the production, I hope that through this development, the development of a set can be directly production demo systems.

Business Analysis

In the development of any system, we want to achieve is a business platform, we first consider a basic electronic business platform which business functions are included?
architecture
The figure shows the electricity supplier to implement a simple module information.

Technology Selection

When technology selection, individuals recommended to follow the following principles:

  1. Meet the actual needs of the business (any business out of the technology is waste wood)
  2. Ability of team members (team members to be realistic, otherwise will be very slow to get started)
  3. Technical Community activity (choice of technology for post-high active troubleshooting is important, more important is that most of the errors others have been tried ...)
  4. Security (essential selection)
  5. Can refer to later Poc, I choose to give OSGI

We showed a very clear theme to be used springbootto implement a webproject, then seize the two key points.
Since the use of Springboot, here we use the latest version 2.2.0.RELEASE, since it is a web project, it is bound to use the web-related technologies, tomcat(springboot built), and we have taken before and after the end of the separation technologies to develop, provide backend api restful front end use jquery& vuejs, since it is a real project, of course, essential to our database, we use MYSQL 8.0+, then we want to java db and interact, we use mybatisas a bridge. the basic technology has been enough for us to use, then follow specific dependent package give Members.

  • SpringBoot 2.2.0.RELEASE
  • Mysql 8.0.18
  • Mybatis 3.4.6

development tools

工预善其事必先利其器The following is a personal tool to select, for reference:

  • IntelliJ IDEA (code tools)
    • Free Mybatis Plugin (SQL methods and help us jump)
    • Lombok (using annotations to save a lot of codes, improve efficiency)
    • Maven Helper (aid-dependent analysis)
    • Restful Toolkit (and the postman can achieve the same effect is simple, while helping us generate part of the test information)
    • ... Other plug-Rengeyouzhi friends ~
  • Mysql Workbench(Mysql tools)
  • PDman (database design tool, the version of the script control Oh well)

Talk is cheap, show me the codes

To say more, not as to point the truth, then we begin our next show it.

Create a single project structure

First we need to create a Maven's parent module, modules for all of us put together all the information, such as service, controllerand so on.

Create Parent Module expensive-shop

  • Open IDEA, select File => New => Project
    create parent module

  • Click Next, each input GroupId&artifactId
    write groupid & artifactid

  • Click Next, modify project name(do not change it does not matter)
    Modify the project name

  • Click Finish

At this point, it generates srcand pom.xmlbecause the project as a parent class project, there will be no code implementation, therefore, delete srcdirectory, and modify pom.xmlthe file.

<?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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/>
    </parent>
    <groupId>com.life-runner</groupId>
    <artifactId>expensive-shop</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>expensive-shop</name>
    <description>develop a on-line shop</description>

    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <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-web</artifactId>
        </dependency>
        <!--spring默认使用yml中的配置,有时候要用传统的xml或properties配置,就需要使用spring-boot-configuration-processor-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--监控端点依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>
    </dependencies>
</project>

2:00 major concern:
1. Review packagingof pom, indicates this is a collection of parent
2. The introduction of parentnode us springboothere is the entire set of project related springboot dependent version control and
from the foregoing, the node is set to version 2.2.0.RELEASEafter, following All groupis org.springframework.bootset version information dependencies are not displayed.

Create child module

And create the same parent class project creation process, in order to create a child modules we need to use to complete the following chart:
create child module

After the above link, I believe we can create our project needed infrastructure environment, and next time we will start the actual coding operations realized.
Gogogo.

Guess you like

Origin www.cnblogs.com/zhangpan1244/p/11793065.html