spring boot web服务
[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
- <?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>- <groupId>com.neo</groupId>
<artifactId>spring-boot-hello</artifactId>
<version>1.0</version>
<packaging>jar</packaging>- <name>spring-boot-hello</name>
<description>Demo project for Spring Boot</description>- <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>- <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>- <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>- com.neo.HelloApplication
- package com.neo;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;- @SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
- com.neo.controller.HelloController
- 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();
}
}
- [root@d java]# mvn clean; mvn compile;mvn package;
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building spring-boot-hello 1.0
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] --- maven-clean-plugin:3.0.:clean (default-clean) @ spring-boot-hello ---
- [INFO] Deleting /data/gateway/java/target
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: .493s
- [INFO] Finished at: Tue Dec :: CST
- [INFO] Final Memory: 14M/481M
- [INFO] ------------------------------------------------------------------------
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building spring-boot-hello 1.0
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] --- maven-resources-plugin:3.0.:resources (default-resources) @ spring-boot-hello ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] Copying resource
- [INFO] Copying resource
- [INFO]
- [INFO] --- maven-compiler-plugin:3.7.:compile (default-compile) @ spring-boot-hello ---
- [INFO] Changes detected - recompiling the module!
- [INFO] Compiling source files to /data/gateway/java/target/classes
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: .593s
- [INFO] Finished at: Tue Dec :: CST
- [INFO] Final Memory: 23M/607M
- [INFO] ------------------------------------------------------------------------
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building spring-boot-hello 1.0
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] --- maven-resources-plugin:3.0.:resources (default-resources) @ spring-boot-hello ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] Copying resource
- [INFO] Copying resource
- [INFO]
- [INFO] --- maven-compiler-plugin:3.7.:compile (default-compile) @ spring-boot-hello ---
- [INFO] Nothing to compile - all classes are up to date
- [INFO]
- [INFO] --- maven-resources-plugin:3.0.:testResources (default-testResources) @ spring-boot-hello ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] skip non existing resourceDirectory /data/gateway/java/src/test/resources
- [INFO]
- [INFO] --- maven-compiler-plugin:3.7.:testCompile (default-testCompile) @ spring-boot-hello ---
- [INFO] Nothing to compile - all classes are up to date
- [INFO]
- [INFO] --- maven-surefire-plugin:2.20.:test (default-test) @ spring-boot-hello ---
- [INFO] No tests to run.
- [INFO]
- [INFO] --- maven-jar-plugin:3.0.:jar (default-jar) @ spring-boot-hello ---
- [INFO] Building jar: /data/gateway/java/target/spring-boot-hello-1.0.jar
- [INFO]
- [INFO] --- spring-boot-maven-plugin:2.0..RELEASE:repackage (default) @ spring-boot-hello ---
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: .883s
- [INFO] Finished at: Tue Dec :: CST
- [INFO] Final Memory: 19M/481M
- [INFO] ------------------------------------------------------------------------
- [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服务的更多相关文章
- 一次spring boot web服务响应缓慢的排查
使用spring boot搭建了一个web服务,部署在docker容器中.使用中出现了一个性能问题:多次接口请求中,偶尔会出现一次响应非常慢的情况.正常情况下接口的响应时间在10-20ms,偶尔会出现 ...
- 【原创】Docker容器及Spring Boot微服务应用
Docker容器及Spring Boot微服务应用 1 什么是Docker 1.1 Docker的出现 问题一:项目实施环境复杂问题 传统项目实施过程中经常会出现“程序在我这跑得好好的,在你那怎么就不 ...
- Spring Boot微服务架构入门
概述 还记得在10年毕业实习的时候,当时后台三大框架为主流的后台开发框架成软件行业的标杆,当时对于软件的认识也就是照猫画虎,对于为什么会有这么样的写法,以及这种框架的优势或劣势,是不清楚的,Sprin ...
- Springboot 系列(五)Spring Boot web 开发之静态资源和模版引擎
前言 Spring Boot 天生的适合 web 应用开发,它可以快速的嵌入 Tomcat, Jetty 或 Netty 用于包含一个 HTTP 服务器.且开发十分简单,只需要引入 web 开发所需的 ...
- 转-spring boot web相关配置
spring boot web相关配置 80436 spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何w ...
- Spring Boot微服务框架的搭建
(1)spring boot简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发 ...
- Spring Cloud第十三篇 | Spring Boot Admin服务监控
本文是Spring Cloud专栏的第十三篇文章,了解前十二篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...
- Spring Boot Web Executable Demo
Spring Boot Web Executable Demo */--> pre.src {background-color: #292b2e; color: #b2b2b2;} pre.sr ...
- 3行代码快速实现Spring Boot Oauth2服务
这里的3行代码并不是指真的只需要写3行代码,而是基于我已经写好的一个Spring Boot Oauth2服务.仅仅需要修改3行数据库配置信息,即可得到一个Spring Boot Oauth2服务. 项 ...
随机推荐
- 【Java面试题】59 Math.round(11.5)等於多少? Math.round(-11.5)等於多少?
Math类中提供了三个与取整有关的方法:ceil.floor.round,这些方法的作用与它们的英文名称的含义相对应,例如,ceil的英文意义是天花板,该方法就表示向上取整,Math.ceil(11. ...
- NSArray打印汉字的方法
(1) NSArray打印汉字 通过重载NSArray的- (NSString *)descriptionWithLocale:(id)locale方法 方法体例如以下: //依据设置的locale ...
- 关于使用_bstr_t的一个坑
编程中需要将_variant_t转换为char*,常用的方法是:(const char*)_bstr_t(c_variant_t); 使用_bstr_t的构造函数: _bstr_t(const _v ...
- CentOS下yum安装PHP,配置php-fpm服务
yum list installed | grep php 先删除已有的php版本 ,执行下面的命令删除php yum remove php-common 然后像安装那样问你是否继续的,输入yes即可 ...
- EF--CodeFirst
1,增加EntityFramework的引用 2,创建实体类 public class Invoice { public Invoice() { LineItems = new List<Lin ...
- MFC-TCP连接代码片段(支援大富的)
BOOL CClientSocketTestDlg::OnInitDialog() { CDialogEx::OnInitDialog(); ........................ // T ...
- Unity随机Prefab,自动前往某点处理
对与U3D AI,看了下,自己做了小功能,以备后用啊! 一,在某区域随机产生某个对象 C# 文件名称为RadomAPoint.cs using UnityEngine; using System.C ...
- Android 使用WebView显示网页
构建WebView就可以显示Web信息.因为我觉得这里会讲述很多方式来实现WebView,所以我决定为每一种方式创建一个对应的Activity,MainActivity通过Button可以点击进入对应 ...
- $.post和jquerySubmit返回json数据获取的区别
$.post("/patrol/patrolDataContent!deleteContent.action",{"ids":ids},function(dat ...
- MVC AJAX Pager Helper
MVCPager 分页控件: Author:杨涛 http://www.webdiyer.com/mvcpager/demos/ajaxpagers/ https://yunpan.cn/cq4HDc ...