使用springboot简单轻松创建helloword SpringBoot系列1-helloword
关于springboot
这是摘自官方的一段话 Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring applications. 意思是说Spring Boot的设计是以最小的可伸缩的配置让你的应用程序尽可能快地运行,
为什么要使用springboot呢?
影响力大:sping团队的力作,Spring Boot致力于在蓬勃发展的快速应用开发领域成为领导者
简单:使编码,配置,部署,监控变简单
快速:能够简单快速构建好一个项目而不使用太复杂的配置
自动化:根据你的配置自动导入相关依赖
实现一个简单的helloword
环境:jdk1.8,maven3.1+(非必须)
开发工具:IDE(Eclipse、IntelliJ 或者其它的)
新建一个maven项目,可以是web工程也可以是java基本工程
配置pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
新建HelloController
@RestController
public class HelloController {
@RequestMapping("/say/{content}")
public String helloword(@PathVariable("content") String content){
return content;
}
}
SpringbootApplication.java
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
运行测试在浏览器访问
http://localhost:8080/say/helloword 可以看到浏览器得到返回结果【helloword】
源码地址:https://github.com/tiankonglanlande/springboot
作 者:天空蓝蓝的
网址导航:http://www.lskyf.com
个人博客:http://www.lskyf.xyz
版权所有,欢迎保留原文链接进行转载:) 大牛高薪工程师都会那些呢?扫码关注公众号了解更多!