spring boot配置service发布服务
在application.yml中配置
server:
port: 8080
context-path: /crm
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/crm
username: root
password: 136735
jpa:
show-sql: true
jackson:
default-property-inclusion: non_null
devtools:
restart:
enabled: true
cxf:
path: /services #使用service发布服务,需要在/crm后面加上/service,
#要添加依赖:否则解析不了,做不了映射 "org.apache.cxf:cxf-spring-boot-starter-jaxrs:$boot_starter_jaxrs_version"
servlet.init: service-list-path: /info jaxrs: component-scan: true
service发布服务
package top.kylewang.crm.controller; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody; import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path; @Path("path")
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPath {
@Path("/p1")
@GET
@Consumes({"application/xml", "application/json"})
public String getString() {
return "path";
}
}
访问 http://localhost:8080//crm/services/path/p1
返回path
带参数的请求。
@Path("QueryProductService")
public interface QueryProductService {
/**
* 查询商品根据Uid
* @return
*/
@Path("/QueryProductBypid")
@GET //post 参数在请求体中,get在url中
@Consumes({"application/xml", "application/json"}) //返回void用consumes
Product QueryProductBypid(@QueryParam("id") String id);
}
url http://127.0.0.1:9001/background/services/QueryProductService/QueryProductBypid?id=556556887752
spring boot配置service发布服务的更多相关文章
- Spring Boot+CXF搭建WebService服务参考资料
pom.xml文件引入包: <!--WerbService CXF依赖--> <dependency> <groupId>org.apache.cxf</gr ...
- spring boot 配置访问其他模块包中的mapper和xml
maven项目结构如下,这里只是简单测试demo,使用的springboot版本为2.1.3.RELEASE 1.comm模块主要是一些mybatis的mapper接口和对应的xml文件,以及数据库表 ...
- Spring Boot 配置 - Consul 配置中心
▶ Spring Boot 依赖与配置 Maven 依赖 <dependencyManagement> <dependencies> <dependency> &l ...
- Redis篇之操作、lettuce客户端、Spring集成以及Spring Boot配置
Redis篇之操作.lettuce客户端.Spring集成以及Spring Boot配置 目录 一.Redis简介 1.1 数据结构的操作 1.2 重要概念分析 二.Redis客户端 2.1 简介 2 ...
- Spring Boot 配置优先级顺序
一般在一个项目中,总是会有好多个环境.比如: 开发环境 -> 测试环境 -> 预发布环境 -> 生产环境 每个环境上的配置文件总是不一样的,甚至开发环境中每个开发者的环境可能也会有一 ...
- Springboot监控之二:Spring Boot Admin对Springboot服务进行监控
概述 Spring Boot 监控核心是 spring-boot-starter-actuator 依赖,增加依赖后, Spring Boot 会默认配置一些通用的监控,比如 jvm 监控.类加载.健 ...
- Spring boot配置多个Redis数据源操作实例
原文:https://www.jianshu.com/p/c79b65b253fa Spring boot配置多个Redis数据源操作实例 在SpringBoot是项目中整合了两个Redis的操作实例 ...
- spring boot配置mybatis和事务管理
spring boot配置mybatis和事务管理 一.spring boot与mybatis的配置 1.首先,spring boot 配置mybatis需要的全部依赖如下: <!-- Spri ...
- Spring boot 配置异步处理执行器
示例如下: 1. 新建Maven 项目 async-executor 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0 ...
随机推荐
- 为什么有这么多 Python版本
Python是出类拔萃的 然而,这是一句非常模棱两可的话.这里的"Python"到底指的是什么? 是Python的抽象接口吗?是Python的通用实现CPython吗(不要把CPy ...
- javascript解析器原理
浏览器在读取HTML文件的时候,只有当遇到<script>标签的时候,才会唤醒所谓的“JavaScript解析器”开始工作. JavaScript解析器工作步骤 1. “找一些东西”: v ...
- apache两种工作模式详解
prefork模式 这个多路处理模块(MPM)实现了一个非线程型的.预派生的web服务器,它的工作方式类似于Apache 1.3.它适合于没有线程安全库,需要避免线程兼容性问题的系统.它是要求将每个请 ...
- linux学习路线图
- 1007: [HNOI2008]水平可见直线[维护下凸壳]
1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 7184 Solved: 2741[Submit][Sta ...
- github命令行下载项目源码
一.git clone [URL] 下载指定ur的源码 $ git clone https://github.com/jquery/jquery 二.指定参数, -b是分支, --depth 1 最新 ...
- Egret 中实现3种状态切换按钮
一.游戏中的常用3种状态按钮 Egret种提供了2种状态切换的按钮ToggleButton. 但是在游戏中常用到3种状态的按钮,比如任务系统的领取.已领取.未领取. 比如下图中宝箱的打开.浏览后打开. ...
- 【JSP】JSP中的Java脚本
前言 现代Web开发中,在JSP中嵌入Java脚本不是推荐的做法,因为这样 不利于代码的维护.有很多好的,替代的方法避免在JSP中写Java脚本.本文仅做为JSP体系技术的一个了解. 类成员定 ...
- [工具] 将Sublime Text 3配置为Java代码编辑器
新建编译器选项 选择菜单栏中的 Tools ——> Build System ——> New Build System ,输入: { "cmd": ["jav ...
- Python3中关于下划线变量和命名的总结
变量 #!-*-coding:utf-8-*- #__author__ = 'ecaoyng' # # 变量 #_xxx,单下划线开头的变量,标明是一个受保护(protected)的变量,原则上不允许 ...