(1):application.properties 配置信息如下
com.didispace.blog.title=Spring Boot
(2):entity 编写如下:
@Component
public class BlogProperties {
@Value("${com.didispace.blog.title}")
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
(3):使用如下:
@Autowired
BlogProperties n;