Springboot学习笔记(一)

Springboot学习笔记(一),第1张

Springboot学习笔记(一)

注意第一个Helloworld项目:浏览发送/hello请求,响应hello,SpringBoot 2

原始SSM:MVC麻烦

1.创建Maven工程

2.引入依赖

 
    
        org.springframework.boot
        spring-boot-starter-parent
        2.3.4.RELEASE
    

 
        
        
            org.springframework.boot
            spring-boot-starter-web
        
 

3.创建主程序

package com.cxy.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

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

4.编写业务

package com.cxy.boot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//@ResponseBody
//@Controller
@RestController
public class HelloController {
    @ResponseBody
    @RequestMapping("/hello")//映射请求
    public String handle01(){
        return "Hello Spring boot2!";
    }
}

5.测试;运行main方法

6.简化配置:application.properties

7.简化部署:打成jar包,直接执行

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

注意取消CMD的快速依赖

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4970944.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存