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);
      }
    }

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

    运行结果如下图:

  • 相关阅读:
    [Typescript] What is a Function Type ? Function Types and Interfaces
    [NPM] Add comments to your npm scripts
    警告: 隐式声明与内建函数‘exit’不兼容 [默认启用]
    小数循环节
    [置顶] API相关工作过往的总结之整体介绍
    [置顶] 如何运行用记事本写的java程序
    Linux进程间通信——使用共享内存
    Linux内核数据包的发送传输
    ESB 企业服务总线
    URAL 1244
  • 原文地址:https://www.cnblogs.com/tanzk/p/7082205.html
Copyright © 2011-2022 走看看