服务化的世界,越来越多应用拆分为微服务,有些为了业务而拆,也有为了技术而拆,也有什么都不知道就瞎拆的,反正就是要微服务。

以下为一个认识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 随笔(一)的更多相关文章

  1. springBoot 随笔(二)

    此文为springBoot 结合 thymeleaf ,解析后台接口数据展示到html页面 基于 springBoot(一)工程. 1/ 引用 thymeleaf 组件依赖 <!-- depen ...

  2. spring-boot随笔

    配置了spring-boot-starter-web的依赖后,会自动添加tomcat和spring mvc的依赖,那么spring boot 会对tomcat和spring mvc进行自动配置 < ...

  3. springboot学习随笔(四):Springboot整合mybatis(含generator自动生成代码)

    这章我们将通过springboot整合mybatis来操作数据库 以下内容分为两部分,一部分主要介绍generator自动生成代码,生成model.dao层接口.dao接口对应的sql配置文件 第一部 ...

  4. springboot学习随笔(二):简单的HelloWorld

    接上章搭建好springboot环境后,开始开发入门级HelloWorld 一.构建简单的springboot项目 1.新建项目,选择Spring/Spring Starter Project 2.N ...

  5. SpringBoot进阶用法-随笔

    SpringBoot进阶用法 实现setApplicationContext //实现ApplicationContextAware接口,重写setApplicationContext方法 publi ...

  6. springboot基础(随笔)

    <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...

  7. Idea下的springboot mysql8.0等报错解决随笔

    cannot load jdbc class path:mysql8.0装载失败,可能原因,驱动名称错误,连接字符串中需要加入时区UTC,否则8.0一定会报错无法连接,关闭SSL 在applicati ...

  8. springboot学习随笔(三):Controller参数映射

    接上章内容,我们看看浏览器参数如何映射到我们的Controller层 我们新建UserController和User实 User.java package com.example.main; impo ...

  9. springboot学习随笔(一):springboot环境构建:eclipse+maven+jdk1.8

    一:所需环境 1.jdk1.8(配置环境变量,可自行搜索相关文档) 2.maven(maven的配置不在赘述,可自行搜索相关文档) 3.eclipse(第三种方式,eclipse集成sts时需要,直接 ...

随机推荐

  1. 2018-2019-2 《网络对抗技术》Exp2 后门原理与应用 20165215

    目录 实验内容 基础问题回答 常用后门工具 Netcat windows 获取 linux 的shell linux 获取 winsdows 的shell 使用nc传输数据 使用nc传文件 Socat ...

  2. Navicat Premium 简体中文版 12.0.16 以上版本国外官网下载地址(非国内)

    国内Navicat网址是:http://www.navicat.com.cn 国外Navicat网址是:http://www.navicat.com 国外的更新比国内的快,而且同一个版本,国内和国外下 ...

  3. SSH 安全加固

    检查密码重用是否受限制 | 身份鉴别 说明:强制用户不重用最近使用的密码,降低密码猜测攻击风险 描述:设置较低的Max AuthTrimes参数将降低SSH服务器被暴力攻击成功的风险. 加固建议:在/ ...

  4. Redis查漏补缺:最易错过的技术要点大扫盲

    考虑到绝大部分写业务的程序员在实际开发中使用Redis时,只会Setvalue和Getvalue两个操作,对Redis整体缺乏一个认知.又恰逢笔者有同事下周要去培训Redis,所以笔者斗胆以Redis ...

  5. radhat6.6上安装oracle12c RAC (二)

    二.GI(Grid Infrastructure)安装 首先将安装包传到node1的目录 2.1 GI软件安装 2.1.1.解压安装包 #su - grid解压 GRID 到 GRID用户的$ORAC ...

  6. [C++ Primer Plus] 第8章、函数探幽(一)程序清单——内联、引用、格式化输入输出、模板、decltype

    程序清单8.1(inline内联函数) #include<iostream> using namespace std; inline double square(double x) {// ...

  7. C# 无法将类型为“__DynamicallyInvokableAttribute”的对象强制转换为类型...

    错误代码: //遍历方法特性 foreach (MethodInfo m in type.GetMethods()) { foreach(Attribute a in m.GetCustomAttri ...

  8. centos设置网卡开机自启动

    1.进入目录/etc/sysconfig/network-scripts/2.修改ifcfg-enxxxxxxxx 文件   (即你的网卡标识命名的配置文件)3. 将ONBOOT=no改成yes4. ...

  9. MySql 查询表结构信息

    select Column_name as 列名,is_nullable as 是否可为空,data_type as 数据类型,column_default as 默认值,case when colu ...

  10. redux&&createStore

    const createStore = (reducer,presetState, enhancer) => { if (typeof presetState === "functio ...