application.properties
server.port=8989 server.servlet.context-path=/springboot_day3 name=xiaoguo
控制器调用
package com.baizhi.controller; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("hello") public class HelloController { @Value("${name}") private String name; @GetMapping("hello") public String hello(){ System.out.println("name="+name); return "hello springboot_day3"; } }