zoukankan      html  css  js  c++  java
  • springboot入门程序

    springboot

    简介

    优点 

    入门程序

    1、加入jar包

    <!--设置spring boot的parent-->
    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.2.RELEASE</version>
    </parent>
    <!--  导入spring boot的web支持-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!--添加Spring boot的插件,可不要-->
    <plugin>
            <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>

    2、编写第一个springboot程序

    @Controller
    @SpringBootApplication
    @Configuration
    public class HelloApplication {
        
        @RequestMapping("hello")
        @ResponseBody
        public String hello(){
            return "hello world!";
        }
        
        public static void main(String[] args) {
            SpringApplication.run(HelloApplication.class, args);
        }
    
    }

    3、代码说明

    1、@SpringBootApplication:Spring Boot项目的核心注解,主要目的是开启自动配置。;

    2、@Configuration:这是一个配置Spring的配置类;

    3、@Controller:标明这是一个SpringMVC的Controller控制器;

    4、main方法:在main方法中启动一个应用,即:这个应用的入口;

  • 相关阅读:
    Flexbox 可视化属性
    latex 数学公式
    迭代器模式 rx 应用
    小程序开发 easy-less 配置
    react-devtool 消息处理渲染 源码理解
    csrf jsonp
    koa1 源码详解1
    Immutable api example
    es6 ajax
    lodash 替换 underscore
  • 原文地址:https://www.cnblogs.com/durui/p/9323652.html
Copyright © 2011-2022 走看看