springboot

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

restful

restful就是提供一堆标准方法例如getput等完成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等目录下的文件变化不会触发重启。

原文地址:https://blog.csdn.net/beidideshu/article/details/134793260

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_42346.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注