Spring Boot Learning four: Spring boot configuration file application.yml

Source: Internet
Author: User

one about Port :

The default port for spring boot is 8080, and if you want to change it, make the following configuration in the configuration file. Serverproperties.class will read this value.

Server:   8081

Another way is if you just want to modify the port number when you start it, you can modify the port number with command-line arguments . The configuration is as follows:Java-jar after packaging Springboot.jar--server.port=8000

two @RestController (Spring has another note @Controller)

That is, @restcontroller = @ResponseBody + @Controller combination annotations.

If the name of the logical view is returned and the page needs to be displayed, use @controller with the View Resolver (resolver) to render the page;

If you return JSON directly, you can use the @RestController.

Three @Autowired

This note is that spring can automatically help you omit the Setter/getter method of the object referenced in the Bean , and it will automatically help you set/get.

  @Autowired annotation, it can annotate class member variables, methods, and constructors to complete the work of automatic assembly. use the @Autowired to eliminate the set,get method.

When the spring container is started,autowiredannotationbeanpostprocessor will scan all the beans in the spring container when it finds that the Bean has the @ When autowired comments, it finds the Bean that matches it ( by default by type ) and injects it into the corresponding place.

Spring Boot Learning four: Spring boot configuration file application.yml

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.