一、建立maven java项目
导入springboot包
二、配置pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ij34.example</groupId> <artifactId>Bootproject</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>Bootproject</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
三、代码测试
package hello; import java.util.Date; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; /** * @author Admin * @date 创建时间:2017年8月28日 下午4:14:54 * @version 1.0 *@type_name SampleController */ @Controller @EnableAutoConfiguration public class SampleController { @RequestMapping("/") @ResponseBody String home(){ return "Hello World:"+new Date(); } public static void main(String[] args) { // TODO Auto-generated method stub SpringApplication.run(SampleController.class, args); } }
附加:spring-boot-cli下载地址
http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/