Spring Boot2.0之 yml的使用

yml

Spring Boot 默认读取   .yml   .properties 结尾的

yml非常好的作用,比properties更节约  结构清晰

server:

  port:  8090

  context-path: /toov5

父级是公用的

一定要注意啊啊啊 空格! port:  8090 中间空格!

package com.toov5.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Index {
 
    @RequestMapping("/index")
    public String index(){
        return "ok";
    }
    
}

启动类:

package com.toov5.controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class app {
   public static void main(String[] args) {
    SpringApplication.run(app.class, args);
}
}

application.yml

server:
  port: 80
 

  启动后:

扫描二维码关注公众号,回复: 3639138 查看本文章

修改成功!

访问

是不是很好玩呀


猜你喜欢

转载自www.cnblogs.com/toov5/p/9820351.html