springboot之helloworld

软件152 谭智馗

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

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

springboot之helloworld_第1张图片

 

2.HelloWorld之pom.xml

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

<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>1.4.0.RELEASEversion>
parent>
  
  <properties>
    <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    <java.version>1.7java.version>
  properties>

  <dependencies>
  <dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-webartifactId>
  dependency>
  
  
  <dependency>  
    <groupId>org.springframework.bootgroupId>  
    <artifactId>spring-boot-devtoolsartifactId>  
    <optional>trueoptional>  
  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);
  }
}

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

运行结果如下图:

 

转载于:https://www.cnblogs.com/tanzk/p/7082205.html

你可能感兴趣的:(springboot之helloworld)