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.example</groupId>
<artifactId>springbootdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build />
<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>
</project>

//代码

 

 


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;
//控制器
@Controller

//启动类 自动扫描 同包类 子包类
@SpringBootApplication

public class HelloController {

@RequestMapping("/hello")
@ResponseBody
String home() {
return "Hello ,spring boot!";
}

public static void main(String[] args) throws Exception {
SpringApplication.run(HelloController.class, args);
//运行之后在浏览器中访问:http://localhost:8080/hello
}

}

 

posted @ 2017-07-10 22:44  随风而逝,只是飘零  阅读(136)  评论(0)    收藏  举报