preface

The technology stack used for the backend was mentioned in the pilot, and this is a primer, starting the project and setting up the scaffolding.

Engineering instructions

The directory structure

├ ─ ─ mldong - admin management end interface ├ ─ ─ component package ├ ─ ─ the config configuration loaded └ ─ ─ modules └ ─ ─ sys ├ ─ ─ dao persistence layer - the layer code can be custom ├ ─ ─ dto dto layer, Can be query result entity, request parameter entity, business entity ├─ enums error code definition ├─ VO VO layer, front-end need what, ├─ ├─ general Exercises, ├─ mlDong-mapper ├─ general Exercises, ├─ mldong-mapper │ ├─ general Exercises, ├─ mldong-mapper │ ├─ general Exercises, ├─ mldong-mapper │ ├─ general Exercises, ├─ mldong-mapper │ ├─ general Exercises, ├─ mldong-mapper │ ├─ ├─ entity class ├─ mapperCopy the code

start

Don’t want screenshots, let’s create them one by one.

Create the base directory structure and files

├── heavy heavy exercises ── heavy heavy exercises ── heavy heavy exercises ── heavy heavy exercises ── heavy heavy exercises ── LoginController. Java └ ─ ─ MldongAdminApplication. Java └ ─ ─ resources ├ ─ ─ application - dev. Yml └ ─ ─ application. Yml └ ─ ─ the test ├── Java, ├── Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ Java, ├─ └ ─ ─ the test └ ─ ─ Java └ ─ ─ the gitkeep └ ─ ─ pom. The XML ├ ─ ─ mldong - generator ├ ─ ─ the SRC ├ ─ ─ the main ├ ─ ─ Java └ ─ ─ the gitkeep └ ─ ─ resources └ ─ ─ . Gitkeep └ ─ ─ the test └ ─ ─ Java └ ─ ─ the gitkeep └ ─ ─ pom. The XML ├ ─ ─ mldong - mapper ├ ─ ─ the SRC ├ ─ ─ the main ├ ─ ─ Java └ ─ ─ the gitkeep └ ─ ─ Resources └ ─ ─. Gitkeep └ ─ ─ the test └ ─ ─ Java └ ─ ─ the gitkeep └ ─ ─ pom. The XML └ ─ ─ pom. The XMLCopy the code

mldong/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>
  <groupId>com.mldong</groupId>
  <artifactId>mldong</artifactId>
  <version>1.0 the SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>mldong</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring-boot.version>2.1.4. The RELEASE</spring-boot.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
	<jwt.version>3.7.0</jwt.version>
    <com.alibaba.druid.version>1.0.18</com.alibaba.druid.version>
    <tk.mybatis.version>4.1.5</tk.mybatis.version>
    <mybatis.spring.boot.starter.version>2.1.0</mybatis.spring.boot.starter.version>
    <mapper.spring.boot.starter.version>2.1.0</mapper.spring.boot.starter.version>
    <pagehelper.spring.boot.starter.version>1.2.12</pagehelper.spring.boot.starter.version>
    <io.springfox-swagger2.version>2.7.0</io.springfox-swagger2.version>
	<swagger-knife.version>2.0.2</swagger-knife.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>
		<! Druid database connection pool -->
		<dependency>
	        <groupId>com.alibaba</groupId>
	        <artifactId>druid</artifactId>
	        <version>${com.alibaba.druid.version}</version>
        </dependency>
		<! -- jwt -->  
	    <dependency>  
	        <groupId>com.auth0</groupId>  
	        <artifactId>java-jwt</artifactId>  
	        <version>${jwt.version}</version>  
	    </dependency>  
	    <! -- tk.mybatis -->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>${mybatis.spring.boot.starter.version}</version>
            </dependency>
            <dependency>
                <groupId>tk.mybatis</groupId>
                <artifactId>mapper</artifactId>
                <version>${tk.mybatis.version}</version>
            </dependency>
            <! --mapper-->
            <dependency>
                <groupId>tk.mybatis</groupId>
                <artifactId>mapper-spring-boot-starter</artifactId>
                <version>${mapper.spring.boot.starter.version}</version>
            </dependency>
            <! --pagehelper-->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>${pagehelper.spring.boot.starter.version}</version>
            </dependency>
            <! -- tk.mybatis -->
            <dependency>
	            <groupId>net.sf.dozer</groupId>
	            <artifactId>dozer</artifactId>
	            <version>${dozer.version}</version>
	        </dependency>
			<! --swaggerui-->
			<dependency>
	            <groupId>io.springfox</groupId>
	            <artifactId>springfox-swagger2</artifactId>
	            <version>${io.springfox-swagger2.version}</version>
	        </dependency>
	        <dependency>
	            <groupId>io.springfox</groupId>
	            <artifactId>springfox-swagger-ui</artifactId>
	            <version>${io.springfox-swagger2.version}</version>
	        </dependency>
			<! --knife4j-->
			<dependency>
			    <groupId>com.github.xiaoymin</groupId>
			    <artifactId>knife4j-spring-boot-starter</artifactId>
			    <! -- Search for the latest version number in Maven's central repository when referencing -->
			    <version>${swagger-knife.version}</version>
			</dependency>
    </dependencies>
</dependencyManagement>
<repositories>
	<! -- Ali Cloud repository, which represents Maven Central and JCenter repository -->
	<repository>
		<id>aliyun</id>
		<name>aliyun</name>
		<url>https://maven.aliyun.com/repository/public</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
</repositories>
<pluginRepositories>
	<! -- Aliyun agent Spring plugin repository -->
	<pluginRepository>
		<id>spring-plugin</id>
		<name>spring-plugin</name>
		<url>https://maven.aliyun.com/repository/spring-plugin</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</pluginRepository>
</pluginRepositories>
<modules>
	<module>mldong-common</module>
	<module>mldong-generator</module>
	<module>mldong-mapper</module>
</modules>
</project>
Copy the code

mldong/mldong-admin/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>mldong</artifactId>
		<groupId>com.mldong</groupId>
		<version>1.0 the SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<properties>
	</properties>
	<artifactId>mldong-admin</artifactId>
	<dependencies>
		<dependency>
		    <groupId>com.mldong</groupId>
		    <artifactId>mldong-common</artifactId>
		    <version>${parent.version}</version>
		</dependency>
		<dependency>
		    <groupId>com.mldong</groupId>
		    <artifactId>mldong-mapper</artifactId>
		    <version>${parent.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<! Springboot hot loading -->
		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>
		<! -- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <! -- Data source -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
        </dependency>
	</dependencies>
	 <build>
		<resources>
	         <resource>
	             <directory>src/main/resources</directory>
	             <includes>
	                 <include>/ * * *</include>
	             </includes>
	         </resource>
	         <resource>
	             <directory>src/main/lib</directory>
	             <targetPath>BOOT-INF/lib/</targetPath>
	             <includes>
	                 <include>**/*.jar</include>
	             </includes>
	         </resource>
	         <resource>
	             <directory>src/main/resources</directory>
	             <targetPath>BOOT-INF/classes/</targetPath>
	         </resource>
	     </resources>
    	<finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <! Skip unit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Copy the code

mldong/mldong-admin/src/main/java/com/mldong/MldongAdminApplication.java

Start the class

package com.mldong;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MldongAdminApplication {
	public static void main(String[] args) { SpringApplication.run(MldongAdminApplication.class, args); }}Copy the code

mldong/mldong-admin/src/main/java/com/mldong/modules/sys/controller/LoginController.java

Log in to the controller, just a Hello World

package com.mldong.modules.sys.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {
	@GetMapping("hello")
	public String hello(a) {
		return "hello world"; }}Copy the code

mldong/mldong-admin/src/main/resources/application.yml

Master profile

server: 
  port: 18080
spring:
  application:
    name: mldong-admin
  profiles:
    active: dev
  jackson:
    default-property-inclusion: non_null
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: ${jdbc.driver-class-name}
    url: ${jdbc.url}
    username: ${jdbc.username}
    password: ${jdbc.password}
    max-idle: ${jdbc.max-idle}
    max-wait: ${jdbc.max-wait}
    min-idle: ${jdbc.min-idle}
  aop:
    proxy-target-class: true
    auto: true
Copy the code

mldong/mldong-admin/src/main/resources/application-dev.yml

Development Environment Configuration

# JDBC configurationjdbc.driver-class-name: com.mysql.cj.jdbc.Driver jdbc.url: jdbc:mysql://localhost:3306/mldong? useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
jdbc.username: root
jdbc.password: 
jdbc.max-idle: 10
jdbc.max-wait: 10000
jdbc.min-idle: 5
Copy the code

mldong/mldong-common/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>mldong</artifactId>
		<groupId>com.mldong</groupId>
		<version>1.0 the SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<properties>
		
	</properties>
	<artifactId>mldong-common</artifactId>
	<dependencies>
		
	</dependencies>
</project>
Copy the code

mldong/mldong-generator/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>mldong</artifactId>
		<groupId>com.mldong</groupId>
		<version>1.0 the SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<properties>
		
	</properties>
	<artifactId>mldong-generator</artifactId>
	<dependencies>
		
	</dependencies>
</project>
Copy the code

mldong/mldong-mapper/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>mldong</artifactId>
		<groupId>com.mldong</groupId>
		<version>1.0 the SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<properties>
		
	</properties>
	<artifactId>mldong-mapper</artifactId>
	<dependencies>
		
	</dependencies>
</project>
Copy the code

Create the project directory file with the simplest directory structure and then import it

File->Import->Maven->Existing Maven Projects

Start running the project

MldongAdminApplication.java

Right-click ->Run As -> Java Application

To access the page

http://localhost:18080/hello

If the project starts normally, hello World will appear on the visit page. At this point, the scaffolding is completed. Hello World is a simple integration with Spring-boot-DevTools and Druid. Mapper will be integrated in the next article.

Add to the repository and push to git repository

slightly

Project source code address

  • The back-end

Gitee.com/mldong/mldo…

  • The front end

Gitee.com/mldong/mldo…

Related articles

Build a suitable for their own rapid development framework – front-end scaffolding

Build a fast development framework for yourself – integrated Mapper

Build a fast development framework for yourself – integration with Swaggerui and KNIfe4J

Build a suitable for their own rapid development framework – universal class packaging unified result return, unified exception handling

Create a quick development framework for yourself – business error code specifications and practices

Build a quick development framework for yourself – framework layering and CURD sample

Create a suitable for their own rapid development framework – Mapper logical deletion and enumeration type specification

Create a suitable framework for rapid development – Hibernate Validator data verification

Create a suitable for their own rapid development framework – code generator principle and implementation

Create a suitable for their own rapid development framework – universal query design and implementation

Build a suitable rapid development framework – rBAC-based permission management

Build a quick development framework for yourself – login and permission blocking

Build a suitable for their own rapid development framework – HTTP request log global processing

To create a suitable for their own rapid development framework – dictionary module design and implementation

Create a suitable for their own rapid development framework – upload module design and implementation

Build a suitable for their own rapid development framework – continuous deployment of one key release script design and implementation