入門程序步驟,建立一個Maven項目。繼承Spring Boot官方提供的父工程。再引入一個Web的應用啓動器。java
建立一個Maven工程,並添加以下配置web
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
@SpringBootApplication @RestController public class ExampleApplication { @GetMapping("/hello") public String hello() { return "Hello Spring Boot!"; } public static void main(String[] args) { SpringApplication.run(ExampleApplication.class, args); } }
瀏覽器訪問http://localhoast:8080/hello
spring