idea版本:ideaIU-2017.2.1.exehtml
源码地址:quickStartjava
补充:git
使用idea建立spring-boot工程github
1)http://start.spring.io/,点击Generate Projectweb
2)使用idea导入生成工程spring
工程结构目录json
<!--添加web模块--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--热启动--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
author.name=小王
public class PropertiesValues { @Value("${author.name}") private String userName; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } }
@RestController public class UserController { @Autowired private PropertiesValues propertiesValues; @RequestMapping("getUser.do") public User getUser(){ User user = new User(); user.setName(propertiesValues.getUserName()); user.setSex(1); return user; } }
运行QuickStartApplication.java中main方法springboot
地址:localhost:8080/getUser.doapp
返回:ide
{"name":"小王","sex":1}