Spring Boot Project Property configuration

Source: Internet
Author: User

First, System configuration file

1.application.properties is the default configuration file after you create a new Springboot project

Examples of configuration such as the following

server.port=8080server.context-path=/girl

2. Recommended ways to use APPLICATION.YML

Examples of configuration such as the following

Server:   8082   Context-path:/girl

Second, YAML

YAML Language Tutorials

Third, practical application

[e-mail protected] Usage

Application.yml

Server
port:8082
Cupsize:b
Age:18
Content: "Cupsize: ${cupsize}, Age: ${age}"

The corresponding injection method in Hellocontroller

@RestController
public class Hellocontroller {

@Value ("${cupsize}")
Private String cupsize;

@Value ("${age}")
Private String age;

@Value ("${content}")
Private String content;

@RequestMapping (value = "/hello", method = Requestmethod.get)
Public String say () {
Return cupsize+ "," +age+ ";" +content;
}
}

Browser output is b,18;cupsize:b, age:18

2.

Spring Boot Project Property configuration

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.