1 搭建Spring-Boot项目
在这里我使用intellij新建spring boot工程;
点击next;
输入Group以及artifact之后。点击next.之后点击web.接着finish就ok了
测试案列,证明spring boot工程搭建完毕;
·1)依赖的pom.xml
4.0.0 com.gosaint.spring.boot.blog initiallizr-start 0.0.1-SNAPSHOT jar initiallizr-start Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 1.5.9.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-web RELEASE org.springframework.boot spring-boot-maven-plugin
测试demo(该类是程序自动生成的)
package com.gosaint.spring.boot.blog.initiallizrstart;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controller@EnableAutoConfiguration@SpringBootApplicationpublic class InitiallizrStartApplication { @RequestMapping("/hello") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(InitiallizrStartApplication.class, args); }}
启动main()方法;如下所示
访问localhost:8080/hello:
好了,就此一个Spring-Boot的web工程已经启动了!