spring boot入门小案例
spring boot 入门小案例搭建
(1) 在Eclipse中新建一个maven project项目,目录结构如下所示:

cn.com.rxyb中存放spring boot的启动类,application.properties中放spring boot相关配置
(2) 在pom.xml中加入spring boot 依赖包

(3)在cn.com.rxyb中新建启动类APP
package cn.com.rxyb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @SpringBootApplication
@EnableAutoConfiguration(exclude= {DataSourceAutoConfiguration.class})
public class App { public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
APP.java启动类
继续在包中创建测试Controller控制器
package cn.com.rxyb;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
public class TestController { @GetMapping("hello")
public String helloword() {
return "hello";
} @GetMapping("hello2")
public String helloworkd2() {
return "hello2";
}
}
TestController.java控制器
(4)接下来可以在启动类APP中右键--->run as---->java Application来启动spring boot。之后打开浏览器输入http://localhost:8080/hello直接访问。

如果想在hello前面加名字空间的话,可以在application.properties中做如下配置:
server.context-path=/demo
这样我们就在hello之前加入了/demo名字空间,在访问hello的时候,hello之前必须加/demo名字空间才可以访问

今天的spring boot入门小案例学习就到这里,明天继续。
spring boot入门小案例的更多相关文章
- Spring Boot入门 and Spring Boot与ActiveMQ整合
1.Spring Boot入门 1.1什么是Spring Boot Spring 诞生时是 Java 企业版(Java Enterprise Edition,JEE,也称 J2EE)的轻量级代替品.无 ...
- Spring Boot 入门案例与配置说明
一.Spring Boot简介 官网地址:http://spring.io/projects/spring-boot Spring Boot可以轻松创建可以运行的独立的,生产级的基于Spring的应用 ...
- Spring Boot 入门之基础篇(一)
原文地址:Spring Boot 入门之基础篇(一) 博客地址:http://www.extlight.com 一.前言 Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是 ...
- 02SpringMvc_springmvc快速入门小案例(XML版本)
这篇文章中,我们要写一个入门案例,去整体了解整个SpringMVC. 先给出整个项目的结构图:
- Springboot 系列(一)Spring Boot 入门篇
注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 由于 J2EE 的开发变得笨重,繁多的配置, ...
- spring boot入门教程——Spring Boot快速入门指南
Spring Boot已成为当今最流行的微服务开发框架,本文是如何使用Spring Boot快速开始Web微服务开发的指南,我们将使创建一个可运行的包含内嵌Web容器(默认使用的是Tomcat)的可运 ...
- Spring Boot 入门之 Web 篇(二)
原文地址:Spring Boot 入门之 Web 篇(二) 博客地址:http://www.extlight.com 一.前言 上一篇<Spring Boot 入门之基础篇(一)>介绍了 ...
- Spring Boot 入门(十一):集成 WebSocket, 实时显示系统日志
以前面的博客为基础,最近一篇为Spring Boot 入门(十):集成Redis哨兵模式,实现Mybatis二级缓存.本篇博客主要介绍了Spring Boot集成 Web Socket进行日志的推送, ...
- Spring Boot 入门(十二):报表导出,对比poi、jxl和esayExcel的效率
本片博客是紧接着Spring Boot 入门(十一):集成 WebSocket, 实时显示系统日志写的 关于poi.jxl和esayExcel的介绍自行百度. jxl最多支持03版excel,所以单个 ...
随机推荐
- 批量导出hive表的建表语句
转的这里的 首先先导出所有的table表 hive -e "use xxxdb;show tables;" > tables.txt 然后再使用hive内置语法导出hive表 ...
- 格式化代码引发的css编译失败
之前在做feather项目,处理IE8下的问题时,写 filter: progid: DXImageTransform.Microsoft.AlphaImageLoader(src='#', sizi ...
- pandas 必背函数操作
1.五个常用属性 index,columns,shape,values,dtypes2.常用函数:set_index,reset_index,del df['column_name'],pd.read ...
- python yield 和 yield from用法总结
#例1. 简单输出斐波那契數列前 N 个数#缺点:该函数可复用性较差,因为 fab 函数返回 None,其他函数无法获得该函数生成的数列#要提高 fab 函数的可复用性,最好不要直接打印出数列,而是返 ...
- 前端性能优化 —— 添加Expires头
简要:添加Expires头能有效的利用浏览器的缓存能力来改善页面的性能,能在后续的页面中有效避免很多不必要的Http请求,WEB服务器使用Expires头来告诉Web客户端它可以使用一个组件的当前副本 ...
- jmeter实例介绍
JMeter基础之一 一个简单的性能测试 测试需求: 1)测试目标网站是fnng.cnblogs.com 和 tt-topia.rhcloud.com 2)测试目的是该网站在负载达到20 QPS 时 ...
- ECMA Script 6_解构赋值_模式匹配
解构赋值 从数组中提取值,按照对应位置,对变量赋值 只要等号右边的值不是对象或数组,就先将其转为对象. 由于 undefined 和 null 无法转为对象,所以对它们进行解构赋值,都会报错 let ...
- windows创建定时任务执行python脚本
一.创建定时任务 \ [程序或脚本]文本框中填的是Python编译器的名称,一般就是python.exe, [起始于]文本框中填的是Python编译器的目录,上图中假设你的Python编译器的完整路径 ...
- C#开发问题汇总
问题1:HTTP 错误 500.21 - Internal Server Error处理程序“NickLeeCallbackHandler”在其模块列表中有一个错误模块“ManagedPipeline ...
- CentOS7 使用systemctl来管理服务
1.建立service文件 以tomcat为例 , 建立tomcat.service文件 #服务说明 [Unit] #服务描述 Description=Tomcat Service #前置需要启动的服 ...