您的位置:首页 > 编程语言 > Java开发

Springboot 框架学习

2017-12-31 20:07 519 查看

Springboot 框架学习

前言

Spring Boot是Spring 官方的顶级项目之一,她的其他小伙伴还有Spring CloudSpring FrameworkSpring Data等等。

简介

Spring Boot可以轻松创建单独的,基于生产级的Spring应用程序,您需要做的可能“仅仅是去运行”。 我们提供了Spring Platform对Spring 框架和第三方库进行处理,尽可能的降低使用的复杂度。大多数情况下Spring Boot应用只需要非常少的配置。

Features(她的特点)

Create stand-alone Spring applications

Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)

快速构建独立的Spring Application,使用内嵌容器,无需部署到外部容器,你要做的仅仅是运行她。

Provide opinionated 'starter' POMs to simplify your Maven configuration

Automatically configure Spring whenever possible

提供众多扩展的‘starter’,通过依赖探知自动配置,你要做的仅仅是添加Maven依赖。

Provide production-ready features such as metrics, health checks and externalized configuration

提供生产环境下的性能健康状态监控及外部化配置,让你时刻掌控她。

Absolutely no code generation and no requirement for XML configuration

无需生成代码及XML配置,一切从简。

通过上面官网的描述,其实我总结下来就两条:

** 依赖探知,自动配置**

[b]一切从简,Just Run ![/b]

尝试

配置你项目的pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>


创建Application.java

@RestController
@EnableAutoConfiguration
public class Application {

@RequestMapping("/")
String index() {
return "Welcome to know Spring Boot !";
}

public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}


Just Run,执行
Application.main()
或者 mvn:
spring-boot:run


启动成功后,访问http://localhost:8080/



可能仅仅不到1分钟便可快速构建、部署、启动一个Web 应用,这就是Spring Boot ~


Springboot 详细的学习资料

https://segmentfault.com/a/1190000008539153

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: