Here is a simple distributed architecture I will write: SpringCloud+SpringBoot+SpringMVC+MyBatis+MySQL

Architecture diagram:

Preparations:

Technical selection:

Use SpringMVC for presentation layer development use MyBatis for persistence layer development Use Spring for component integration and management of declarative transactions use Maven as dependency management and build management tool Use BootStrap front-end style framework to generate page effects use MD5 encryption algorithm to encrypt user passwords SpringMVC exception mapping mechanism for unified management of exception information using MyBatis PageHelper to achieve persistent layer paging using jQuery Pagination plug-in to display paging page numbers on the page using BootStrap modal frame component to display elastic layer window display tables or forms and so on Using jQuery’s on() function to dynamically generate the element binding event response function using zTree framework to display the tree structure of Permission data on the page by maintaining the parent node ID in the database to implement the tree structure of Permission data by dynamically querying each use User assigned license menu to achieve fine-grained permission control microservice project using SpringBoot to develop specific business modules using Eureka service of SpringCloud as the microservice registry using Feign of SpringCloud to encapsulate microservice information, The goal is to call remote methods like local methods. Use RestTemplate to upload binary data to the Provider. Use RestTemplate to download binary data to Consumer. Use Activiti as a process management framework to implement a real name authentication process using FastDF S acts as a remote distributed file server for users to upload files and uses James mail server to send emails. PostMan tests the services provided by Provider and Freemarker acts as view technology in SpringBoot environment

Create each project:

Create parent project: CrowdFundingParent

Create the subproject: ConsumerPortal

Create child project: ConsumerManager

All other projects are created this way

The packaging of the sub-project is jar, so you can finish it directly

Create dependency management and build management in pom.xml for the CrowdFundingParent project

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > < version > 0.0.1 - the SNAPSHOT < / version > < packaging > pom < / packaging > < modules > < module > RegisterCenterEureka < module > <module>CommonBean</module> <module>CommonUtil</module> <module>CommonFeign</module> <module>ProviderDatabase</module> <module>ProviderActiviti</module> <module>ConsumerPortal</module> <module>ConsumerManager</module> </modules> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> Piler < maven.com. Source > 1.8 < / maven.com piler. Source > < maven.com piler. Target > 1.8 < / maven.com piler. Target > < junit version > 4.12 < / junit version > < log4j. Version > 1.2.17 < / log4j version > < / properties > < dependencyManagement > <dependencies> <dependency> <groupId>org.csource</groupId> <artifactId>fastdfs-client-java</artifactId> 1.27 the SNAPSHOT < version > < / version > < / dependency > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR1</version> <type>pom</type> <scope>import</scope>  </dependency> <dependency> <groupId>org.springframework.boot</groupId> < artifactId > spring - the boot - dependencies < / artifactId > < version > 1.5.12. RELEASE < / version > < type > pom < type > <scope>import</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.0.4</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> < version > 1.0.31 < / version > < / dependency > < the dependency > < groupId > org. Mybatis. Spring. The boot < / groupId > < artifactId > mybatis - spring - the boot - starter < / artifactId > < version > 1.3.0 < / version > < / dependency > < the dependency > < the groupId > ch. Qos. Logback < / groupId > < artifactId > logback - core < / artifactId > < version > 1.2.3 < / version > < / dependency > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <! -- Activiti scenario launcher --> <dependency> <groupId>org. Activiti </groupId> < artifactId > activiti - spring - the boot - starter - basic < / artifactId > < version > 5.21.0 < / version > < / dependency > < / dependencies > </dependencyManagement> </project>Copy the code

Create dependency management and build management in pom.xml of the ConsumerPortal subproject

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1 -snapshot </version> </parent> <artifactId>ConsumerPortal</artifactId> <dependencies> <dependency> <groupId>org.csource</groupId> <artifactId>fastdfs-client-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonBean</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonFeign</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonUtil</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>  </dependencies> </project>Copy the code

The jar package error

If there is a problem with the online solution, it may be that there is a problem with the Maven environment configuration, or the parent project does not have a version number

Create dependency management and build management in pom.xml of the ConsumerManager subproject

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>ConsumerManager</artifactId> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonBean</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonFeign</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonUtil</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>  </dependencies> </project>Copy the code

Create dependency management and build management in pom.xml of the ProviderActiviti subproject

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>ProviderActiviti</artifactId> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <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> <scope>test</scope> </dependency> <! - eureka - server client - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonBean</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonFeign</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonUtil</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <! -- Activiti scenario launcher --> <dependency> <groupId>org. Activiti </groupId> <artifactId>activiti-spring-boot-starter-basic</artifactId> </dependency> </dependencies> </project>Copy the code

Create dependency management and build management in pom.xml of the ProviderDatabase subproject

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>ProviderDatabase</artifactId> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <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> <scope>test</scope> </dependency> <! - eureka - server client - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonBean</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonFeign</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonUtil</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>  </dependencies> </project>Copy the code

Create dependency management and build management in pom.xml of the RegisterCenterEureka child project

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>RegisterCenterEureka</artifactId> <dependencies> <! - eureka - server server - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> </dependencies> </project>Copy the code

 

Create dependency management and build management in pom.xml of the CommonFeign subproject

The < 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" > The < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > com < / groupId > < artifactId > CrowdFundingParent < / artifactId > <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>CommonFeign</artifactId> <dependencies> <! - Feign scene starter - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-feign</artifactId> </dependency> <dependency> <groupId>com</groupId> <artifactId>CommonBean</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> </dependencies> </project>Copy the code

Other projects without dependency management and construction management, if need to add later

Create the main startup class for each project

 

RegisterCenterEureka

@EnableEurekaServer

@SpringBootApplication

ProviderDatabase

@EnableEurekaClient

@MapperScan(“com.mapper”)

@SpringBootApplication

ProviderActiviti

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

ConsumerPortal

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

ConsumerManager

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

Case diagram:

Create yML files for each project

RegisterCenterEureka

server:
  port: 84
eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:84/eureka
Copy the code

ProviderDatabase

server: port: 83 mybatis: config-location: classpath:mybatis/mybatis.cfg.xml mapper-locations: - classpath:mybatis/mapper/*Mapper.xml spring: application: name: ProviderDatabase datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/atcrowdfunding? rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8 username: root password: root dbcp2: min-idle: 5 initial-size: 5 max-total: 5 max-wait-millis: 200 eureka: client: service-url: defaultZone: http://localhost:84/eurekaCopy the code

Create the mybatis directory

Create mybatis. CFG. XML

<? The XML version = "1.0" encoding = "utf-8"? > <! DOCTYPE configuration PUBLIC "- / / mybatis.org//DTD Config / 3.0 / EN" "http://mybatis.org/dtd/mybatis-3-config.dtd" > <configuration> <settings> <setting name="cacheEnabled" value="true" /> </settings> </configuration>Copy the code

ProviderActiviti

server: port: 82 spring: application: name: ProviderActiviti datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/atcrowdfunding? rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8 username: root password: root dbcp2: min-idle: 5 initial-size: 5 max-total: 5 max-wait-millis: 200 eureka: client: service-url: defaultZone: http://localhost:84/eurekaCopy the code

ConsumerPortal

server:
  port: 80
eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:84/eureka
spring:
  freemarker:
    template-loader-path: classpath:/templates/
    suffix: .page
crowdfunding.tracker.config.location: classpath:/tracker.conf
Copy the code

Create the Templates directory

To create the tracker. Conf

Tracker_server = 192.168.0.100:22122Copy the code

ConsumerManager

server:
  port: 81
eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:84/eureka
spring:
  freemarker:
    template-loader-path: classpath:/templates/
    suffix: .page
Copy the code

Create the Templates directory

Now write a home page display function test

Display the home page: Using Freemarker as the view technology in the SpringBoot environment, create an index.page and copy the index

Modify the page

The modified

A slash before a path indicates that the path is under the classpath

The modified

Adding a Static Resource

Copy the following

Create a static folder in the classpath. The directory for storing static resources must be static

Create ProtalHandler. Java

@Controller public class PortalHandler { @RequestMapping("/main") public String toIndexPage() { return "index"; }}Copy the code

Start the project

Start the RegisterCenterEureka

Then start the subproject ConsumerPortal

http://localhost:80/main defaults to port 80 in the browser, so you can also directly http://localhost/main

The running project yML configuration is 80 so the browser uses port 80

That’s when the page comes up.

Create libraries and tables in the database

CREATE DATABASE atcrowdfunding;
USE atcrowdfunding;
CREATE TABLE `t_member` (
  `member_id` INT(11) NOT NULL AUTO_INCREMENT,
  `login_acc` VARCHAR(100) DEFAULT NULL,
  `login_pwd` VARCHAR(100) DEFAULT NULL,
  `nick_name` VARCHAR(100) DEFAULT NULL,
  `real_name` VARCHAR(100) DEFAULT NULL,
  `card_num` VARCHAR(100) DEFAULT NULL,
  `phone_num` VARCHAR(20) DEFAULT NULL,
  `email_addr` VARCHAR(100) DEFAULT NULL,
  `auth_status` TINYINT(4) DEFAULT NULL,
  `acc_type` TINYINT(4) DEFAULT NULL,
  `company` TINYINT(4) DEFAULT NULL,
  PRIMARY KEY (`member_id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
Copy the code

Note: this is just a simple setup, the work to prepare is here, here I share my own initial project CrowdFundingParent, child project can be derived from the parent project.

You can use the original built project to write features.

I wrote some functions: portal: login and registration, real-name authentication process after login, management: real-name authentication audit in business audit, process management in business management

The completed project is shared with CrowdFundingParent. Time to write other features.