zoukankan      html  css  js  c++  java
  • 01springboot快速入门

    SpringBoot快速入门


    springboot的宗旨是习惯大于配置,所以spring里面大量使用了默认的配置来简化spring的配置。spring Boot的主要优点:

    • 为所有Spring开发者更快的入门
    • 开箱即用,提供各种默认配置来简化项目配置
    • 内嵌式容器简化Web项目
    • 没有冗余代码生成和XML配置的要求

    快速搭建一个springboot helloworld

    开发环境java8,maven,idea

    1.修改pom文件

     <!-- Inherit defaults from Spring Boot -->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.0.RELEASE</version>
        </parent>
    
        <!-- Add typical dependencies for a web application -->
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
        </dependencies>
    
        <!-- Package as an executable jar -->
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    

    2.编写helloworld

    @RestController
    @EnableAutoConfiguration
    public class HelloWorld {
        @RequestMapping("/hello")
        public String index() {
            return "Hello World";
        }
        public static void main(String[] args) throws Exception {
            SpringApplication.run(HelloWorld.class, args);
        }
    }
    

    3. 在浏览器中访问http://localhost:8080/hello

  • 相关阅读:
    虚拟机centOs和主机ssh互连
    centos7 利用yum安装mysql8.0
    MySQL触发器trigger的使用
    VMware虚拟机优化
    VM tools的安装
    CentOS下tar包和rpm包的区别
    如何解决VMware-vmx.exe无法彻底删除的问题
    JVM结构及堆的划分
    MYSQL: set names utf8是什么意思?
    collate utf8_bin和uft-8_general_ci是什么意思?
  • 原文地址:https://www.cnblogs.com/hxh969012806/p/9038566.html
Copyright © 2011-2022 走看看