"Springboot" multi-module project structure construction

Source: Internet
Author: User

Objective:

Must learn to springboot basic knowledge

Brief introduction:

Takes an opinionated view of building Production-ready Spring applications. Spring Boot Favors convention over-configuration and is designed-to get-up and running as quickly as possible.

Tools:

JDK8

apache-maven-3.5.2

IntelliJ Idea 2018.1.3 x64

Preparatory work

Through the previous chapters to transform, more in line with enterprise needs.

Do a simple Web Flux project first

Theoretical analysis

Model layers: Models
Persistence layer: Persostence
Presentation layer: Web

Web Dependency persostence
Persostence Dependent model

Select Project Right click on new–> Module, choose Maven Next Fill Artifactid (web) Then, always next to finish;

And then porting the code from the original project.

And so on, the other one was built.

All right! Below to the Pom file to join the dependency, everyone should also have to look at the above I write the preparation work to put? Yes, just do it!

First-app-demo

    1. Need to be manually modified to POM
    2. <modules> is automatically added when creating a new subdirectory, not manually
<?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.lwc</groupid > <artifactId>first-app-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <module s> <module>web</module> <module>persostence</module> &LT;MODULE&GT;MODEL&L  T;/module> </modules> <!--modified to pom--> <packaging>pom</packaging> <!--model layer: Model Persistence layer: Persostence presentation layer: Web Web Dependency persostence persostence dependent model Web Usercontro Ller, Userrepository, User--<name>first-app-demo</name> <description>demo Proje  CT for Spring boot</description>  <parent> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-start Er-parent</artifactid> <version>2.0.2.RELEASE</version> <relativePath/> <!--look Up parent from repository-</parent> <properties> <project.build.sourceencoding>utf-8 </project.build.sourceEncoding> <project.reporting.outputencoding>utf-8</ project.reporting.outputencoding> <java.version>1.8</java.version> </properties> &LT;DEP Endencies> <dependency> <groupId>org.springframework.boot</groupId> <            Artifactid>spring-boot-starter-webflux</artifactid> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-test</artif Actid> <scope>test</scope> </dependency> <dependency> <groupId>io.projectreactor</groupId> <a        Rtifactid>reactor-test</artifactid> <scope>test</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactid>lombok</art ifactid> </dependency> </dependencies> <build> <plugins> <plu Gin> <groupId>org.springframework.boot</groupId> <artifactid>spring-boo t-maven-plugin</artifactid> </plugin> </plugins> </build></project>

Web.pom

    1. Web dependent persostence (copy persostence <parent> inside <groupId>, <version>, <artifactId> to Web Pom File inside)
<?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.0http://        Maven.apache.org/xsd/maven-4.0.0.xsd "> <parent> <artifactId>first-app-demo</artifactId> <groupId>com.lwc</groupId> <version>0.0.1-SNAPSHOT</version> </parent> < Modelversion>4.0.0</modelversion> <artifactId>web</artifactId> <dependencies> < !--Add to Persostence dependency-<dependency> <groupId>com.lwc</groupId> <art Ifactid>persostence</artifactid> <version>0.0.1-SNAPSHOT</version> </dependency&    Gt </dependencies></project>

Persostence.pom

    1. Persostence dependent model (the principle is the same as above)
<?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.0http://        Maven.apache.org/xsd/maven-4.0.0.xsd "> <parent> <artifactId>first-app-demo</artifactId> <groupId>com.lwc</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <        Modelversion>4.0.0</modelversion> <artifactId>persostence</artifactId> <dependencies> <!--Add to model dependency-<dependency> <groupId>com.lwc</groupId> <     Artifactid>model</artifactid> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies></project>

Model.pom

    1. You don't have to rely on anything.
<?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.0http:// Maven.apache.org/xsd/maven-4.0.0.xsd ">    <parent>        <artifactid>first-app-demo</ artifactid>        <groupId>com.lwc</groupId>        <version>0.0.1-SNAPSHOT</version>    </parent>    <modelVersion>4.0.0</modelVersion>    <artifactid>model</ Artifactid></project>

Last build, start the project. Complete!

SOURCE download

Https://github.com/eddie-code/SpringBootDemo/tree/master/first-app-demo

"Springboot" multi-module project structure construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.