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
- Need to be manually modified to POM
- <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> <MODULE>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> <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
- 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
- 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
- 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