Spring Boot and springboot

Source: Internet
Author: User

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.

 

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.