springboot——helloworld入门

springboot

简化spring开发,约定大于配置,提供完成restful的框架。注解、配置等完成。

restful

restful就是提供一堆标准的方法,例如get,put等完成http的网站操作。

helloworld入门

注解

  1. @SpringBootApplication
    用于表示SpringBoot应用中的启动类,相当于@EnableAutoConfiguration、@EnableAutoConfiguration和@ComponentScan三个注解的结合体。
  2. @RestController
    用于表示controller层的组件,与@Controller注解的不同在于,相当于在每个请求处理方法上都添加了@ResponseBody注解,这些方法都将返回JSON格式数据。
    3.@RequestMapping(“/hello”)
    相当于映射到hello
    4.@SpringBootTest
    用于指定测试类启用Spring Boot Test功能,默认会提供Mock环境

代码

package com.weiz.helloworld;

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

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


package com.weiz.helloworld.web;

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 @ Spring Boot!!!";
    }
}

other

spring.devtools.restart.enabled=true表示开启热部署功能,如果设置为false,则关闭热部署功能。
spring.devtools.restart.additional-paths=src/main/java表示指定额外的目录作为重启的触发器,当这些目录下的文件发生变化时,会触发重启12。默认情况下,只有classpath目录下的文件变化才会触发重启。
spring.devtools.restart.exclude=WEB-INF/**表示排除某些目录或文件不作为重启的触发器,当这些目录或文件发生变化时,不会触发重启12。默认情况下,/META-INF/maven,/META-INF/resources,/resources,/static,/public,/templates等目录下的文件变化不会触发重启。

相关推荐

  1. docker从入门入土

    2023-12-10 17:40:02       59 阅读
  2. 入门 PyTorch

    2023-12-10 17:40:02       63 阅读
  3. C++<span style='color:red;'>入门</span>

    C++入门

    2023-12-10 17:40:02      49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-10 17:40:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-10 17:40:02       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-10 17:40:02       82 阅读
  4. Python语言-面向对象

    2023-12-10 17:40:02       91 阅读

热门阅读

  1. Python3 基本数据类型 ----20231209

    2023-12-10 17:40:02       47 阅读
  2. mysql中information_schema.tables字段说明

    2023-12-10 17:40:02       62 阅读
  3. GO设计模式——1、简单工厂模式(创建型)

    2023-12-10 17:40:02       60 阅读
  4. 开源软件:JumpServer、DataEase、MeterSphere

    2023-12-10 17:40:02       67 阅读
  5. 【周报2023.12.09】

    2023-12-10 17:40:02       68 阅读
  6. c++ 类和对象-封装意义一

    2023-12-10 17:40:02       63 阅读
  7. 用格里高利公式求给定精度的PI值

    2023-12-10 17:40:02       63 阅读
  8. Vue笔记(一)基础

    2023-12-10 17:40:02       66 阅读