zoukankan      html  css  js  c++  java
  • 体验SpringBoot

    体验SpringBoot

    1、介绍

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。Spring Boot不需要任何xml配置即可实现Spring 的所有配置。

    Spring Boot具有如下特性:

    • 独立运行的Spring 项目
    • 内嵌Servlet 容器
    • 提供starter简化Maven 配置
    • 自动配置Spring
    • 准生产的应用监控
    • 无代码生成和xml配置

    2、在idea下创建模块,添加spring boot特性

    1. idea已经集成了spring boot插件,创建模块时,选中spring initiallizr即可。

      1540379099546

    2. 填写相关信息:

      1540379224175

    3. 选择web->web

      1540379403575

    4. 创建成功后

      1540379586730

    3、运行spring boot程序

    1. 编写程序,添加注解

      package com.it18zhang;
      
      import org.springframework.boot.SpringApplication;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RestController;
      
      //新增的注解
      @RestController
      @SpringBootApplication
      public class MySpringbootApplication {
      	// 新增部分
          @RequestMapping("/hello")
          public String sayHello(){
              System.out.println("hello world");
              return "hello world" ;
          }
      
          public static void main(String[] args) {
              SpringApplication.run(MySpringbootApplication.class, args);
          }
      }
      
    2. 运行程序

      右键点击,选择运行菜单:

      1540380129223

    3. 检查控制台输出

      1540380211987

    4. 使用浏览器访问如下地址

      http://localhost:8080/hello
      
    5. 访问结果

      • 控制输出hello world

        1540380437388

      • 浏览器中显式hello world

        1540380483520

  • 相关阅读:
    BZOJ3779: 重组病毒
    BZOJ3112 [ZJOI2013]防守战线
    BZOJ4011 [HNOI2015]落忆枫音
    BZOJ2726 [SDOI2012]任务安排
    BZOJ1492 [NOI2007]货币兑换
    BZOJ1597 [USACO2008]土地购买
    BZOJ3611 [HEOI2014]大工程
    BZOJ3991 [SDOI2015]寻宝游戏
    BZOJ3675 [APIO2014]序列分割
    BZOJ1010 [HNOI2008]玩具装箱
  • 原文地址:https://www.cnblogs.com/xupccc/p/9845564.html
Copyright © 2011-2022 走看看