一:首先安装spring boot插件
两种方式安装,
1:使用myeclipse自带的安装插件的功能
help> install from catalog> 将出现下面的界面,搜寻spring boot 点击install安装
2:使用maven工程,在pom.xml中添加spring boot依赖,将会添加spring boot插件
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.4.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
二:在resource下面建立static,templates,application.properites文件夹。工程中的静态文件放在static文件夹下,工程开启后将会直接映射到static文件夹。可以直接访问下面的文件
三:创建工程入口:在main所属的类上使用@SpringBootApplication注解,说明这是一个spring boot 工程
四:创建一个controller
@Controller public class DemoController { @ResponseBody @RequestMapping("/hello") public String helloWorld() { // TODO Auto-generated method stub return "Hello world"; }
@ResponseBody @RequestMapping(value="/pojo",method=RequestMethod.GET) public User showUser(@RequestParam("name") String name){ //@RequestParam接收从url传送过来的参数 User u=new User(); u.setId(3); u.setUsername(name); u.setAddress("武当山"); u.setBirthday(new Date()); u.setSex("male"); return u; }
}
五:启动spring boot 工程,使用浏览器访问,成功。
六:整合mybatis,在mybatis中添加配置文件,spring boot将会自动扫描,加载配置
七:添加依赖插件,从Maven reporsities寻找要添加的插件,添加