SpringBoot入门程序

1.环境

     jdk1.8             maven3.6.1      IDEA2017

 

2.创建项目

 

这样一个项目就完成了创建,若是单纯使用maven创建项目,可以去官网导入依赖包

<!--  父文件,用来真正管理所有项目的jar包 -->
<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.1.6.RELEASE</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- 引入依赖  -->
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
   </dependency>

接下来能看的到

在启动类HellostrengthApplication中

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


//将此类标注为主程序类,是程序的入口
@SpringBootApplication
public class HellostrengthApplication {

   public static void main(String[] args) {
      SpringApplication.run(HellostrengthApplication.class, args);
   }
}

 

2.TestController类

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

//这个类的所有方法返回的数据直接写给浏览器,(如果是对象转为json数据)
/*@Controller*/
@RestController
public class TestController {


    //此前有@ResponeBody标签,已经被@RestController取代


    @RequestMapping("/hello")
    public String mapping(){
        return "6666666";
    }
}

 

运行结果

SpringBoot忒爽了!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值