zoukankan      html  css  js  c++  java
  • springboot之helloworld

    软件152 谭智馗

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。

    1.Hello World之创建maven project(spring-boot-hello)

    2.HelloWorld之pom.xml

    直接在pom.xml中加入下面几段代码

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
    </parent>
      
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
      </properties>
    
      <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      
      <!-- 热部署-->
      <dependency>  
        <groupId>org.springframework.boot</groupId>  
        <artifactId>spring-boot-devtools</artifactId>  
        <optional>true</optional>  
      </dependency>

    2.HelloWorld之coding

    新建class(HelloController)

    package com.cqvie.spring_boot_hello;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class HelloController {
        @RequestMapping("/hello")
        public String hello(){
            return "hello";
        }
    
    }

    3.编写启动类

    package com.cqvie.spring_boot_hello;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class App 
    {
      public static void main(String[] args){
          SpringApplication.run(App.class, args);
      }
    }

    到这里就可以了,下面跑起来试试

    运行结果如下图:

  • 相关阅读:
    企业版证书打包APP发布,安装后闪退问题解决。
    Swift 与 Object-C 交互 (Swift版本为:1.2)
    iOS开发-代码片段(Code Snippets)提高开发效率
    iOS开发-Object-C可变参数函数
    MAC-Zsh安装与使用——终极Shell
    Git-学习笔记(常用命令集合)
    CSS动画,2D和3D模块
    CSS定位与布局
    CSS基础
    CSS概述
  • 原文地址:https://www.cnblogs.com/tanzk/p/7082205.html
Copyright © 2011-2022 走看看