spring boot-01 认识spring boot和入门程序

 

认识spring boot :

特性:

  • Create stand-alone Spring applications 

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

  • Provide opinionated 'starter' dependencies to simplify your build configuration

  • Automatically configure Spring and 3rd party libraries whenever possible

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

  • Absolutely no code generation and no requirement for XML configuration

 

独立的标准的spring应用

嵌入tomcat jetty 或者 Undertow directly    ,不需要部署war包

提供可选的启动器依赖简化配置--例如,这个依赖替代了之前springmvc的配置。

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

尽可能自动配置spring 和第三方

提供可用于生产的特性,度量标准,健康检查,外部化配置

不需要生成代码和xml配置

入门程序

  • 方式一

从spring网站创建

https://spring.io/quickstart

创建之后,下载到本地。

下载的压缩包可以直接导入idea。这就是一个完整的maven项目工程。

 

在main入口同级文件包下就可以自定义一个controller

 

HellowController 

package springboot.springboothello.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HellowController {


    @RequestMapping("/hello")
    public  String testHellow(){
        return "Hello springboot.";
    }
}

 重启容器,就可以通过url访问了:

http://localhost:8080/hello

 

  • 方式二

idea直接创建

后面的步骤和之前类似

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值