[root@d java]# tree -I target

.
├── pom.xml
└── src
├── main
│   ├── java
│   │   └── com
│   │   └── neo
│   │   ├── controller
│   │   │   └── HelloController.java
│   │   └── HelloApplication.java
│   └── resources
└── test
└── java

9 directories, 3 files
[root@d java]#

pom.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
  2.  
  3. <groupId>com.neo</groupId>
    <artifactId>spring-boot-hello</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
  4.  
  5. <name>spring-boot-hello</name>
    <description>Demo project for Spring Boot</description>
  6.  
  7. <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    </parent>
  8.  
  9. <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    </properties>
  10.  
  11. <dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    </dependency>
    </dependencies>
    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
    </project>
  12.  
  13. com.neo.HelloApplication
  1. package com.neo;
  2.  
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.SpringApplication;
  4.  
  5. @SpringBootApplication
    public class HelloApplication {
    public static void main(String[] args) {
    SpringApplication.run(HelloApplication.class, args);
    }
    }
  1. com.neo.controller.HelloController
  1. package com.neo.controller;
    import org.springframework.web.bind.annotation.RestController;
    import org.springframework.web.bind.annotation.RequestMapping;
    @RestController
    public class HelloController {
    @RequestMapping("/")
    public String index(){
    return "Hello Spring Boot 2.0!";
    }
    @RequestMapping("/t123")
    public String t123(){
    return "this.t123()"+this.getClass().getName()+Thread.currentThread().getStackTrace()[1].getMethodName();
    }
    }
  2.  
  1. [root@d java]# mvn clean; mvn compile;mvn package;
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building spring-boot-hello 1.0
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-clean-plugin:3.0.:clean (default-clean) @ spring-boot-hello ---
  9. [INFO] Deleting /data/gateway/java/target
  10. [INFO] ------------------------------------------------------------------------
  11. [INFO] BUILD SUCCESS
  12. [INFO] ------------------------------------------------------------------------
  13. [INFO] Total time: .493s
  14. [INFO] Finished at: Tue Dec :: CST
  15. [INFO] Final Memory: 14M/481M
  16. [INFO] ------------------------------------------------------------------------
  17. [INFO] Scanning for projects...
  18. [INFO]
  19. [INFO] ------------------------------------------------------------------------
  20. [INFO] Building spring-boot-hello 1.0
  21. [INFO] ------------------------------------------------------------------------
  22. [INFO]
  23. [INFO] --- maven-resources-plugin:3.0.:resources (default-resources) @ spring-boot-hello ---
  24. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  25. [INFO] Copying resource
  26. [INFO] Copying resource
  27. [INFO]
  28. [INFO] --- maven-compiler-plugin:3.7.:compile (default-compile) @ spring-boot-hello ---
  29. [INFO] Changes detected - recompiling the module!
  30. [INFO] Compiling source files to /data/gateway/java/target/classes
  31. [INFO] ------------------------------------------------------------------------
  32. [INFO] BUILD SUCCESS
  33. [INFO] ------------------------------------------------------------------------
  34. [INFO] Total time: .593s
  35. [INFO] Finished at: Tue Dec :: CST
  36. [INFO] Final Memory: 23M/607M
  37. [INFO] ------------------------------------------------------------------------
  38. [INFO] Scanning for projects...
  39. [INFO]
  40. [INFO] ------------------------------------------------------------------------
  41. [INFO] Building spring-boot-hello 1.0
  42. [INFO] ------------------------------------------------------------------------
  43. [INFO]
  44. [INFO] --- maven-resources-plugin:3.0.:resources (default-resources) @ spring-boot-hello ---
  45. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  46. [INFO] Copying resource
  47. [INFO] Copying resource
  48. [INFO]
  49. [INFO] --- maven-compiler-plugin:3.7.:compile (default-compile) @ spring-boot-hello ---
  50. [INFO] Nothing to compile - all classes are up to date
  51. [INFO]
  52. [INFO] --- maven-resources-plugin:3.0.:testResources (default-testResources) @ spring-boot-hello ---
  53. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  54. [INFO] skip non existing resourceDirectory /data/gateway/java/src/test/resources
  55. [INFO]
  56. [INFO] --- maven-compiler-plugin:3.7.:testCompile (default-testCompile) @ spring-boot-hello ---
  57. [INFO] Nothing to compile - all classes are up to date
  58. [INFO]
  59. [INFO] --- maven-surefire-plugin:2.20.:test (default-test) @ spring-boot-hello ---
  60. [INFO] No tests to run.
  61. [INFO]
  62. [INFO] --- maven-jar-plugin:3.0.:jar (default-jar) @ spring-boot-hello ---
  63. [INFO] Building jar: /data/gateway/java/target/spring-boot-hello-1.0.jar
  64. [INFO]
  65. [INFO] --- spring-boot-maven-plugin:2.0..RELEASE:repackage (default) @ spring-boot-hello ---
  66. [INFO] ------------------------------------------------------------------------
  67. [INFO] BUILD SUCCESS
  68. [INFO] ------------------------------------------------------------------------
  69. [INFO] Total time: .883s
  70. [INFO] Finished at: Tue Dec :: CST
  71. [INFO] Final Memory: 19M/481M
  72. [INFO] ------------------------------------------------------------------------
  73. [root@d java]# java -jar target/spring-boot-hello-1.0.jar com.neo.HelloApplication

http://11.21.1.2:8080/t123

this.t123()com.neo.controller.HelloControllert123

spring boot web服务的更多相关文章

  1. 一次spring boot web服务响应缓慢的排查

    使用spring boot搭建了一个web服务,部署在docker容器中.使用中出现了一个性能问题:多次接口请求中,偶尔会出现一次响应非常慢的情况.正常情况下接口的响应时间在10-20ms,偶尔会出现 ...

  2. 【原创】Docker容器及Spring Boot微服务应用

    Docker容器及Spring Boot微服务应用 1 什么是Docker 1.1 Docker的出现 问题一:项目实施环境复杂问题 传统项目实施过程中经常会出现“程序在我这跑得好好的,在你那怎么就不 ...

  3. Spring Boot微服务架构入门

    概述 还记得在10年毕业实习的时候,当时后台三大框架为主流的后台开发框架成软件行业的标杆,当时对于软件的认识也就是照猫画虎,对于为什么会有这么样的写法,以及这种框架的优势或劣势,是不清楚的,Sprin ...

  4. Springboot 系列(五)Spring Boot web 开发之静态资源和模版引擎

    前言 Spring Boot 天生的适合 web 应用开发,它可以快速的嵌入 Tomcat, Jetty 或 Netty 用于包含一个 HTTP 服务器.且开发十分简单,只需要引入 web 开发所需的 ...

  5. 转-spring boot web相关配置

    spring boot web相关配置 80436 spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何w ...

  6. Spring Boot微服务框架的搭建

    (1)spring boot简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发 ...

  7. Spring Cloud第十三篇 | Spring Boot Admin服务监控

    本文是Spring Cloud专栏的第十三篇文章,了解前十二篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...

  8. Spring Boot Web Executable Demo

    Spring Boot Web Executable Demo */--> pre.src {background-color: #292b2e; color: #b2b2b2;} pre.sr ...

  9. 3行代码快速实现Spring Boot Oauth2服务

    这里的3行代码并不是指真的只需要写3行代码,而是基于我已经写好的一个Spring Boot Oauth2服务.仅仅需要修改3行数据库配置信息,即可得到一个Spring Boot Oauth2服务. 项 ...

随机推荐

  1. 【Java面试题】59 Math.round(11.5)等於多少? Math.round(-11.5)等於多少?

    Math类中提供了三个与取整有关的方法:ceil.floor.round,这些方法的作用与它们的英文名称的含义相对应,例如,ceil的英文意义是天花板,该方法就表示向上取整,Math.ceil(11. ...

  2. NSArray打印汉字的方法

    (1) NSArray打印汉字 通过重载NSArray的- (NSString *)descriptionWithLocale:(id)locale方法 方法体例如以下: //依据设置的locale ...

  3. 关于使用_bstr_t的一个坑

    编程中需要将_variant_t转换为char*,常用的方法是:(const char*)_bstr_t(c_variant_t); 使用_bstr_t的构造函数:  _bstr_t(const _v ...

  4. CentOS下yum安装PHP,配置php-fpm服务

    yum list installed | grep php 先删除已有的php版本 ,执行下面的命令删除php yum remove php-common 然后像安装那样问你是否继续的,输入yes即可 ...

  5. EF--CodeFirst

    1,增加EntityFramework的引用 2,创建实体类 public class Invoice { public Invoice() { LineItems = new List<Lin ...

  6. MFC-TCP连接代码片段(支援大富的)

    BOOL CClientSocketTestDlg::OnInitDialog() { CDialogEx::OnInitDialog(); ........................ // T ...

  7. Unity随机Prefab,自动前往某点处理

    对与U3D  AI,看了下,自己做了小功能,以备后用啊! 一,在某区域随机产生某个对象 C# 文件名称为RadomAPoint.cs using UnityEngine; using System.C ...

  8. Android 使用WebView显示网页

    构建WebView就可以显示Web信息.因为我觉得这里会讲述很多方式来实现WebView,所以我决定为每一种方式创建一个对应的Activity,MainActivity通过Button可以点击进入对应 ...

  9. $.post和jquerySubmit返回json数据获取的区别

    $.post("/patrol/patrolDataContent!deleteContent.action",{"ids":ids},function(dat ...

  10. MVC AJAX Pager Helper

    MVCPager 分页控件: Author:杨涛 http://www.webdiyer.com/mvcpager/demos/ajaxpagers/ https://yunpan.cn/cq4HDc ...