zoukankan      html  css  js  c++  java
  • Spring Boot 之Hello Word

    Spring Boot官网:http://projects.spring.io/spring-boot/

    环境准备:maven 3.3.5、jdk8、Idea

    1.创建maven项目工程

    2.引入starters

     1 <parent>
     2     <groupId>org.springframework.boot</groupId>
     3     <artifactId>spring-boot-starter-parent</artifactId>
     4     <version>1.5.11.RELEASE</version>
     5 </parent>
     6 <dependencies>
     7     <dependency>
     8         <groupId>org.springframework.boot</groupId>
     9         <artifactId>spring-boot-starter-web</artifactId>
    10     </dependency>
    11 </dependencies>

    3.创建主程序

    1 @SpringBootApplication
    2 public class HelloWorldMainApplication {
    3 
    4     public static void main(String[] args){
    5         //Spring 应用启动起来
    6         SpringApplication.run(HelloWorldMainApplication.class, args);
    7     }
    8 }

    4.创建一个Controller

    1 @Controller
    2 public class HelloController {
    3 
    4     @RequestMapping("/hello")
    5     @ResponseBody
    6     public String hello(){
    7         return "Hello Word!";
    8     }
    9 }

    5.运行主方法,并在浏览器输入:localhost:8080/hello ,就会出现Hello Word!

    6.也可以打包成jar包 进行部署

    url:https://docs.spring.io/spring-boot/docs/1.5.11.RELEASE/reference/htmlsingle/#getting-started-first-application-executable-jar

    这个插件,可以将应用打包成一个jar包 
    1 <build>
    2     <plugins>
    3         <plugin>
    4             <groupId>org.springframework.boot</groupId>
    5             <artifactId>spring-boot-maven-plugin</artifactId>
    6         </plugin>
    7     </plugins>
    8 </build>
  • 相关阅读:
    docker 清理日志文件
    POJ2182 Lost Cows
    POJ3468
    楼兰图腾
    P2024 [NOI2001]食物链
    POJ1733 Parity game
    洛谷P1196 [NOI2002]银河英雄传说
    洛谷P1955 [NOI2015]程序自动分析
    CF 660 C. Uncle Bogdan and Country Happiness
    CF 660A&B
  • 原文地址:https://www.cnblogs.com/xkl520xka/p/8748038.html
Copyright © 2011-2022 走看看