spring boot 入门 1
2016-10-25 10:18
302 查看
1,新建一个maven 工程。
2, 在pom.xml中加入依赖关系:
1) 加入parent的关系,让它程序自动下载到所有spring boot要用的主要jar文件。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
2)加入web相关的开发包
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3)简单的代码:
package com;
@RestController
@SpringBootApplication
public class App {
@RequestMapping("/")
public String hello(){
return "Hello world!";
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
其中@SpringBootApplication申明让spring
boot自动给程序进行必要的配置,等价于以默认属性使用@Configuration,@EnableAutoConfiguration和@ComponentScan
@RestController返回json字符串的数据,直接可以编写RESTFul的接口;
2, 在pom.xml中加入依赖关系:
1) 加入parent的关系,让它程序自动下载到所有spring boot要用的主要jar文件。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
2)加入web相关的开发包
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3)简单的代码:
package com;
@RestController
@SpringBootApplication
public class App {
@RequestMapping("/")
public String hello(){
return "Hello world!";
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
其中@SpringBootApplication申明让spring
boot自动给程序进行必要的配置,等价于以默认属性使用@Configuration,@EnableAutoConfiguration和@ComponentScan
@RestController返回json字符串的数据,直接可以编写RESTFul的接口;
相关文章推荐
- Spring Boot 入门之基础构建篇(一)
- 为什么选择Spring Boot作为微服务的入门级微框架
- Spring Boot 快速入门
- Spring Boot入门开发之明月千城(一)
- spring boot初级入门书目录
- Spring Boot 入门之 Web 篇(二)
- Spring Boot入门实例
- Spring Boot 快速入门
- Spring Boot 官方文档学习(一)入门及使用
- Spring Boot入门——JPA
- Spring Boot教程(十四)快速入门
- Spring Boot 入门教程
- Spring Boot入门helloworld
- Spring boot入门一 环境搭建HelloWorld
- Spring Boot学习笔记-入门篇
- 【spring boot】9.spring boot+spring-data-jpa的入门使用,实现数据持久化
- Spring Boot学习入门之统一异常处理详解
- spring boot 基础学习 -- 入门项目
- Spring Boot入门初体验(3)--配置logback日志
- Spring Boot干货系列:(一)优雅的入门篇