server.port=9090
server.context-path=/helloboot
---------------------------------------------------------------------------------
book.author=ll
book.name=SpringBoot
@RestController
@SpringBootApplication
public class Application{
@Value("${book.author}")
private String bookAuthor;
@Value("${book.name}")
private String bookName;
@RequestMapping("/")
String index() {
return "book name is :"+bookName+"and book author is :"+bookAuthor;
}
public static void main (String []args) {
SpringApplication.run(Application.class,args)
}
}
-----------------------------------------------------------------------------------
author.name=ll
author.age=23
@Component
@ConfigrationProperties(prefix="author".locaton="classpath:config/author.properties")
public class AuthorSettings() {
private String name;
private Long age;
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public Long getAge() {
return age;
}
public void setAge(Long age) {
this.age=age;
}
}
@RestController
@Application
public class Application {
@Autowired
private AuthorSettings authorSettings
@RequestMapping("/")
public String index() {
return "author name:"+authorSettings.getName()+"author age :"+authorSettings.getAge();
}
public static void main (String [] args) {
SpringApplication.run(Application.class,args);
}
}
-----------------------------------------------------------------------------------



