在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. LeetCode——Implement Trie (Prefix Tree)

    Description: Implement a trie with insert, search, and startsWith methods. Note:You may assume that ...

  2. 二叉树的实现(Java语言描述)

    实现二叉树   并先序遍历之. package 二叉树的实现; public class BinaryTree<T> { class Node { int value; // 该节点存储的 ...

  3. Junit3和Junit4使用区别

    在项目经常会用到单元测试,这里对Junit在开发中的使用标准及使用方法进行简单的介绍. 1.包目录的定义以及相关jar包的添加 2.Junit3和Junit4分别对测试类的编写 所测试的源代码: pa ...

  4. sencha touch NavigationView 源码详解(注释)

    Ext.define('Ext.navigation.View', { extend: 'Ext.Container', alternateClassName: 'Ext.NavigationView ...

  5. [Noi2016]区间[离散化+线段树维护+决策单调性]

    4653: [Noi2016]区间 Time Limit: 60 Sec  Memory Limit: 256 MBSubmit: 621  Solved: 329[Submit][Status][D ...

  6. URI Scheme注册伪协议实现远程命令执行

    Windows配置注册表注册伪协议 1.新建伪协议项 WIN+R 输入regedit 打开注册表,在注册表HKEY_CLASSES_ROOT键中新建一个项,项的名字就是你伪协议的名字,例如我注册一个c ...

  7. Dokcer制作nginx镜像,提交镜像至仓库

    生成Dockerfile FROM docker.io/hagaico/centos-base-6.5:latest MAINTAINER yatho yatho@163.com ENV DEBIAN ...

  8. idea如何打war包?(部署tomcat后具有class文件)

  9. 什么是webpack?

    https://www.webpackjs.com/concepts/ https://webpack.github.io/ 本质上,webpack 是一个现代 JavaScript 应用程序的静态模 ...

  10. HDU-1011 Starship Troopers(树形dp)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...