在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发布服务的更多相关文章

  1. Spring Boot+CXF搭建WebService服务参考资料

    pom.xml文件引入包: <!--WerbService CXF依赖--> <dependency> <groupId>org.apache.cxf</gr ...

  2. spring boot 配置访问其他模块包中的mapper和xml

    maven项目结构如下,这里只是简单测试demo,使用的springboot版本为2.1.3.RELEASE 1.comm模块主要是一些mybatis的mapper接口和对应的xml文件,以及数据库表 ...

  3. Spring Boot 配置 - Consul 配置中心

    ▶ Spring Boot 依赖与配置 Maven 依赖 <dependencyManagement> <dependencies> <dependency> &l ...

  4. Redis篇之操作、lettuce客户端、Spring集成以及Spring Boot配置

    Redis篇之操作.lettuce客户端.Spring集成以及Spring Boot配置 目录 一.Redis简介 1.1 数据结构的操作 1.2 重要概念分析 二.Redis客户端 2.1 简介 2 ...

  5. Spring Boot 配置优先级顺序

    一般在一个项目中,总是会有好多个环境.比如: 开发环境 -> 测试环境 -> 预发布环境 -> 生产环境 每个环境上的配置文件总是不一样的,甚至开发环境中每个开发者的环境可能也会有一 ...

  6. Springboot监控之二:Spring Boot Admin对Springboot服务进行监控

    概述 Spring Boot 监控核心是 spring-boot-starter-actuator 依赖,增加依赖后, Spring Boot 会默认配置一些通用的监控,比如 jvm 监控.类加载.健 ...

  7. Spring boot配置多个Redis数据源操作实例

    原文:https://www.jianshu.com/p/c79b65b253fa Spring boot配置多个Redis数据源操作实例 在SpringBoot是项目中整合了两个Redis的操作实例 ...

  8. spring boot配置mybatis和事务管理

    spring boot配置mybatis和事务管理 一.spring boot与mybatis的配置 1.首先,spring boot 配置mybatis需要的全部依赖如下: <!-- Spri ...

  9. Spring boot 配置异步处理执行器

    示例如下: 1. 新建Maven 项目 async-executor 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0 ...

随机推荐

  1. (原创)Android Binder设计与实现 - 实现篇(1)

    本文属于原创作品,转载请注明出处并放于明显位置,原文地址:http://www.cnblogs.com/albert1017/p/3849585.html 前言 在学习Android的Binder机制 ...

  2. C语言变量的存储布局

    分析以下代码中变量存储空间如何分配: //MemSeg.c: 代码无意义,仅供分析用 #include <stdio.h> #include <stdlib.h> //mall ...

  3. Writing Reentrant and Thread-Safe Code(译:编写可重入和线程安全的代码)

    Writing Reentrant and Thread-Safe Code 编写可重入和线程安全的代码 (http://www.ualberta.ca/dept/chemeng/AIX-43/sha ...

  4. ANDROID – 單色漸層效果的改良 – GRADIENT SCRIMS(转)

    本篇是根據 +Roman Nurik 在 2014/11/24 發佈的一篇 G+ 而來.看到他發文後,起了好奇心,就根據他提出的方法嘗試著實作,並將之排列呈現,直接從視覺上做個比較. 他在 G+ 的發 ...

  5. Material Design系列第五篇——Working with Drawables

    Working with Drawables This lesson teaches you to Tint Drawable Resources Extract Prominent Colors f ...

  6. sql查看本机IP地址

    CREATE FUNCTION [dbo].[GetCurrentIP] () ) AS BEGIN ); SELECT @IP_Address = client_net_address FROM s ...

  7. 【转】strlen源码

    strlen源码剖析 学习高效编程的有效途径之一就是阅读高手写的源代码,CRT(C/C++ Runtime Library)作为底层的函数库,实现必然高效.恰好手中就有glibc和VC的CRT源代码, ...

  8. 【Spring Boot&&Spring Cloud系列】Spring Boot初识

    项目代码地址:https://github.com/AndyFlower/Spring-Boot-Learn/tree/master/Spring-boot-helloworld 一.Spring B ...

  9. css笔记 - transition学习笔记(二)

    开始把7,8月份学的css整理一下 transition过渡 1. CSS transition transition过渡 :用于当元素 从一种样式变换为另一种样式 时为元素添加效果. 2. tran ...

  10. Apache服务器SSL双向认证配置

    以Win32版Apache与OpenSSL为例,介绍从创建数字证书到Apache配置的整个过程,希望对读者有所帮助. Apache是目前最流行的WEB服务器之一,借助OpenSSL库,我们可以在Apa ...