本文共 2266 字,大约阅读时间需要 7 分钟。
搭建Maven的环境,不然开发太不方便了,下载Maven,设置环境变量,配置settings.xml,设置本地仓库,这里就不再赘述了,网上一搜一大堆
设置STS的 Maven(Window-Preferences-Maven-User Settings),设置User Settings为上面的settings.xml
创建一个基于maven 的项目,pom文件中加入 Spring Boot 需要的库
org.springframework.boot spring-boot-starter-parent 1.3.3.RELEASE org.springframework.boot spring-boot-starter-web
public class User { private String username; private String classname; private String stuno; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getClassname() { return classname; } public void setClassname(String classname) { this.classname = classname; } public String getStuno() { return stuno; } public void setStuno(String stuno) { this.stuno = stuno; }}
@RestController@EnableAutoConfigurationpublic class SampleController { @RequestMapping("/") public Listhome() { List users = new ArrayList (); for (int i = 0; i < 3; i++) { User user = new User(); user.setClassname("软件" + i); user.setStuno("10000" + i); user.setUsername("张三" + i); users.add(user); } return users; }}
public class App { public static void main(String[] args) throws Exception { SpringApplication.run(SampleController.class, args); }}
转载地址:http://ymupo.baihongyu.com/