Spring Boot and springboot
Spirng Boot build
1. Enter the command mvn archetype: generate-Dinteractivemodel = false-DgroupId = com. immoc-DartifactId = first-app-by-maven-Dversion = 1.0.0-SNAPSHOT.
2. Graphic Interface
Enter start. spring. io in the browser to enter spring Initializr.
Enter Group, Artifact, Search for dependencies, select Reactive Web, and download it.
The first Sping Boot program
Springboot Startup Mode
Use the doscommand to start
Method 1: Go to the project directory and start it through mvn spring-boot: run. Enter the address.
Method 2: Go to the project directory and use mvn install to compile the project. The project * is automatically generated in the target directory *. jar file, enter the target directory, and enter the command java-jar *. jar to start.
Here, the command can contain parameters. For multi-Environment configuration, java-jar * can be used to facilitate the development and production environments *. jar -- spring. profiles. active = prod (dev, test)
Start in Eclipse
Method 3: run application. java directly, right-click and select Java Application.
Project property Configuration
Method 1: Open the project. Properties configuration file, modify the port as follows, enter http: // ip address: 8081/renren access
Server. port = 8081
Server. context-path =/renren
Method 2 (recommended ):
1. Create an applicatin. yml file in the project and modify the configuration according to the following format. Note: The attribute names and attribute values must be separated by spaces (for example, url: value)
Server:
Post: 8081
2. Reference, via annotation @ Value ("$ (configuration file property name )")
3.
For example:
Girl:
CupSize: 80
Age: 16 through annotation @ ConfigurationProperties, @ Component, @ AutoWired
Iv. Use of Controller
Test 1: http: // localhost/renrem/say/100 or http: // localhost/renrem/100/Say, which can be abbreviated as @ GetMapping ("/say ")
Test 2:Http: // localhost/renrem/100/Say? Id = 100
V. Database Operations
Spring-Data-JPA
Vi. Transaction operations
Add the annotation @ Transactional before the method to control it.