springBoot 随笔(一)
服务化的世界,越来越多应用拆分为微服务,有些为了业务而拆,也有为了技术而拆,也有什么都不知道就瞎拆的,反正就是要微服务。
以下为一个认识springBoot的简单过程
1/eclipse 新建 maven项目,pom文件添加依赖
<!-- 引用父工程,里面包含一些基础的类库引用,当然也可以使用自定义 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent> <dependencies>
<!-- web组件 提供web相关类库支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 前台模板组件 thymeleaf前台渲染-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies> <build>
<plugins>
<!-- maven运行插件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2 / 新建资源文件夹 src/main/resources
新建配置文件 application.properties ,新增配置
#设置端口
server.port=8081
3/项目根目录设置启动类
package com.hux.stu.dydatasorce; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; /**
* Hello world!
*
*/
@SpringBootApplication
public class App
{
public static void main( String[] args )
{
SpringApplication.run(App.class, args);
}
}
4/启动方式 直接main方法启动 run as
启动成功
Tomcat started on port(s): 8081 (http)
Started App in 3.461 seconds (JVM running for 3.789)
5/此应用开始发布服务
package com.hux.stu.dydatasorce.controller; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** rest请求 响应字符串 */
@RestController
public class AppController {
/**
* 带输入参数设置方法
* @param pathParam
* @return
*/
@RequestMapping("hello/{pathParam}")
public String MyDemoInfo(@PathVariable("pathParam")String pathParam) { return "测试服务发布"+pathParam;
} }
6/访问 http://127.0.0.1:8081/hello/hux 会正常响应数据: 测试服务发布hux
到此一个简单的springBoot发布的服务完成。是不是跟以前的服务简单许多了
springBoot 随笔(一)的更多相关文章
- springBoot 随笔(二)
此文为springBoot 结合 thymeleaf ,解析后台接口数据展示到html页面 基于 springBoot(一)工程. 1/ 引用 thymeleaf 组件依赖 <!-- depen ...
- spring-boot随笔
配置了spring-boot-starter-web的依赖后,会自动添加tomcat和spring mvc的依赖,那么spring boot 会对tomcat和spring mvc进行自动配置 < ...
- springboot学习随笔(四):Springboot整合mybatis(含generator自动生成代码)
这章我们将通过springboot整合mybatis来操作数据库 以下内容分为两部分,一部分主要介绍generator自动生成代码,生成model.dao层接口.dao接口对应的sql配置文件 第一部 ...
- springboot学习随笔(二):简单的HelloWorld
接上章搭建好springboot环境后,开始开发入门级HelloWorld 一.构建简单的springboot项目 1.新建项目,选择Spring/Spring Starter Project 2.N ...
- SpringBoot进阶用法-随笔
SpringBoot进阶用法 实现setApplicationContext //实现ApplicationContextAware接口,重写setApplicationContext方法 publi ...
- springboot基础(随笔)
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...
- Idea下的springboot mysql8.0等报错解决随笔
cannot load jdbc class path:mysql8.0装载失败,可能原因,驱动名称错误,连接字符串中需要加入时区UTC,否则8.0一定会报错无法连接,关闭SSL 在applicati ...
- springboot学习随笔(三):Controller参数映射
接上章内容,我们看看浏览器参数如何映射到我们的Controller层 我们新建UserController和User实 User.java package com.example.main; impo ...
- springboot学习随笔(一):springboot环境构建:eclipse+maven+jdk1.8
一:所需环境 1.jdk1.8(配置环境变量,可自行搜索相关文档) 2.maven(maven的配置不在赘述,可自行搜索相关文档) 3.eclipse(第三种方式,eclipse集成sts时需要,直接 ...
随机推荐
- 关于 IIS 的 Management Service Delegation 配置 备份
在MSDN没找到关于使用APPCMD备份IIS的"Management Service Delegation"模块配置命令. 到IIS的配置文件存放目录下,几番搜索,查到%wind ...
- 解决 IntelliJ IDEA Tomcat 控制台中文输出乱码问题
解决办法 找到安装IDEA的bin目录将idea.exe.vmoptions和idea64.exe.vmoptions两个文件打开分别在文件最末尾添加-Dfile.encoding=UTF-8
- [Offer收割] 编程练习赛63
题目1 : 命名 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 有两个公司想要合并,第一个公司的名字是一个字符串S,第二个公司的名字是一个字符串T. 合并后的新公司是这样 ...
- Derivative of Softmax Loss Function
Derivative of Softmax Loss Function A softmax classifier: \[ p_j = \frac{\exp{o_j}}{\sum_{k}\exp{o_k ...
- 2018年-2019年第二学期第六周C#学习个人总结
在这一周,我学习了5.4抽象类和接口.首先,抽象类当中我知道了C#允许在定义方法时不写方法体,不包含方法体的方法为抽象方法,抽象方法必须使用abstract关键字来修饰例如:abstract void ...
- cssselector元素定位
转自https://blog.csdn.net/qq_40024178/article/details/78945651 一.概述 cssSelector也是一种常用的选择器,CSS locator比 ...
- Tag
C# ASP.NET SQL SERVER .Net Entity Framework JS Question Records Others
- three.js初探,立体几何入手(一)
前言:首先先推荐一篇博客,关于webgl原理,讲的非常之通俗易懂了 图解WebGL&Three.js工作原理 webGL可以理解为openGL ES2.0 (webGL2.0 - openG ...
- C#项目中操作Excel文件——使用NPOI库
转载自:http://blog.csdn.net/dcrmg/article/details/52356236# 感谢-牧野- 实际C#项目中经常会涉及到需要对本地Excel文件进行操作,特别是一些包 ...
- 【Redis】windows下redis服务的安装
下载地址: https://github.com/MicrosoftArchive/redis/releases Redis 支持 32 位和 64 位.这个需要根据你系统平台的实际情况选择,这里我们 ...