1. Version selection of springcloud and SpringBoot
The versions of SpringBoot and SpringCloud are specified in the official documents, Official location ; You can also enter the web address in the browser https://start.spring.io/actuator/info , put the obtained JSON string into the online JSON parsing tool. Once parsed, you can see the results. The parsed data is as follows;
{ "git": { "branch": "ceb7d8739f1b3d841fd5f61630fefcb829c183eb", "commit": { "id": "ceb7d87", "time": "2020-12-11T13:37:01Z" } }, "build": { "version": "0.0.1-SNAPSHOT", "artifact": "start-site", "versions": { "spring-boot": "2.4.1", "initializr": "0.10.0-SNAPSHOT" }, "name": "start.spring.io website", "time": "2020-12-11T13:39:31.767Z", "group": "io.spring.start" }, "bom-ranges": { "azure": { "2.0.10": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE", "2.1.10": "Spring Boot >=2.1.0.RELEASE and <2.2.0.M1", "2.2.4": "Spring Boot >=2.2.0.M1 and <2.3.0.M1", "2.3.5": "Spring Boot >=2.3.0.M1" }, "codecentric-spring-boot-admin": { "2.0.6": "Spring Boot >=2.0.0.M1 and <2.1.0.M1", "2.1.6": "Spring Boot >=2.1.0.M1 and <2.2.0.M1", "2.2.4": "Spring Boot >=2.2.0.M1 and <2.3.0.M1", "2.3.1": "Spring Boot >=2.3.0.M1 and <2.5.0-M1" }, "solace-spring-boot": { "1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1", "1.1.0": "Spring Boot >=2.3.0.M1 and <2.5.0-M1" }, "solace-spring-cloud": { "1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1", "1.1.1": "Spring Boot >=2.3.0.M1 and <2.5.0-M1" }, "spring-cloud": { "Finchley.M2": "Spring Boot >=2.0.0.M3 and <2.0.0.M5", "Finchley.M3": "Spring Boot >=2.0.0.M5 and <=2.0.0.M5", "Finchley.M4": "Spring Boot >=2.0.0.M6 and <=2.0.0.M6", "Finchley.M5": "Spring Boot >=2.0.0.M7 and <=2.0.0.M7", "Finchley.M6": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1", "Finchley.M7": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2", "Finchley.M9": "Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE", "Finchley.RC1": "Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE", "Finchley.RC2": "Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE", "Finchley.SR4": "Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT", "Finchley.BUILD-SNAPSHOT": "Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3", "Greenwich.M1": "Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE", "Greenwich.SR6": "Spring Boot >=2.1.0.RELEASE and <2.1.999.BUILD-SNAPSHOT", "Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.999.BUILD-SNAPSHOT and <2.2.0.M4", "Hoxton.SR9": "Spring Boot >=2.2.0.M4 and <2.3.8.BUILD-SNAPSHOT", "Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.3.8.BUILD-SNAPSHOT and <2.4.0.M1", "2020.0.0-M3": "Spring Boot >=2.4.0.M1 and <=2.4.0.M1", "2020.0.0-M4": "Spring Boot >=2.4.0.M2 and <=2.4.0-M3", "2020.0.0-M6": "Spring Boot >=2.4.0.M4 and <2.4.2-SNAPSHOT", "2020.0.0-SNAPSHOT": "Spring Boot >=2.4.2-SNAPSHOT" }, "spring-cloud-alibaba": { "2.2.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1" }, "spring-cloud-gcp": { "2.0.0-RC2": "Spring Boot >=2.4.0-M1 and <2.5.0-M1" }, "spring-cloud-services": { "2.0.3.RELEASE": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE", "2.1.8.RELEASE": "Spring Boot >=2.1.0.RELEASE and <2.2.0.RELEASE", "2.2.6.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.RELEASE", "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1" }, "spring-geode": { "1.2.12.RELEASE": "Spring Boot >=2.2.0.M5 and <2.3.0.M1", "1.3.7.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", "1.4.0": "Spring Boot >=2.4.0-M1" }, "spring-statemachine": { "2.0.0.M4": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1", "2.0.0.M5": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2", "2.0.1.RELEASE": "Spring Boot >=2.0.0.RELEASE" }, "vaadin": { "10.0.17": "Spring Boot >=2.0.0.M1 and <2.1.0.M1", "14.4.4": "Spring Boot >=2.1.0.M1 and <2.5.0-M1" }, "wavefront": { "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1", "2.1.0-SNAPSHOT": "Spring Boot >=2.4.0-M1" } }, "dependency-ranges": { "okta": { "1.2.1": "Spring Boot >=2.1.2.RELEASE and <2.2.0.M1", "1.4.0": "Spring Boot >=2.2.0.M1 and <2.4.0-M1", "1.5.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1" }, "mybatis": { "2.0.1": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE", "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1" }, "camel": { "2.22.4": "Spring Boot >=2.0.0.M1 and <2.1.0.M1", "2.25.2": "Spring Boot >=2.1.0.M1 and <2.2.0.M1", "3.3.0": "Spring Boot >=2.2.0.M1 and <2.3.0.M1", "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1" }, "open-service-broker": { "2.1.3.RELEASE": "Spring Boot >=2.0.0.RELEASE and <2.1.0.M1", "3.0.4.RELEASE": "Spring Boot >=2.1.0.M1 and <2.2.0.M1", "3.1.1.RELEASE": "Spring Boot >=2.2.0.M1 and <2.4.0-M1" } } }
Then select a relatively stable spring cloud and use this spring cloud to determine the versions of other tools;
The spring cloud version selected this time is Hoxton SR9, spring cloud version is 2.3.5 RELEASE;
2. Basic creation
- First, create a maven project. This Maven project is a parent project component, especially its pom file, which can be inherited by subsequent subclass projects;
- Understand conventions > configuration > coding, so for many things, especially pom files and yml configuration, it is best to have a set of basic templates as specifications; Otherwise, it's easy to make mistakes by following your own, but the configuration may be relatively less;
- Then write the basic business logic code;
This is roughly the creation routine of a basic project, because spring cloud is actually built on the SpringBoot project;
Attention
- In the pom of the parent project In the XML file, the content of the tag < packaging > is pom. It also contains < dependencymanagement >, which contains the label < dependencies >. And all subclass projects will follow the version number of the parent class.
- The < dependencymanagement > tag declares dependency and does not reference, so the sub project is still the imported project that needs to be displayed. The child project will only take the version and scope of the parent project.
- When using placeholders in Mybatis, if character data is passed in, they will be used #{} with single quotation marks to prevent sql injection. If you use ${}, you do not use single quotes. In this way, in short, if it is a condition, it is best to use #{}. If it is a query result and table, you need to use ${}.
- Annotations @ Autowired and @ Resource can be used to inject bean dependent objects, that is, some objects created through bean annotations or < bean >.