1.引入两个需要的jar

        <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.</version>
</dependency>

2.配置webservice类

package com.btw.court.webService;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService; @WebService
public interface PayWebService { @WebMethod
String say(@WebParam(name="arg0")String arg0); }

3.配置webservice实现类

package com.btw.court.webService.impl;

import com.btw.court.webService.PayWebService;

import javax.jws.WebService;

@WebService(targetNamespace = "http://say.com")//对应wsdl中的命名空间xmlns:tns
public class PayWebServiceImpl implements PayWebService { @Override
public String say(String arg0) {
return null;
} }

4.配置springboot配置类

package com.btw.court.config;

import com.btw.court.webService.PayWebService;
import com.btw.court.webService.impl.PayWebServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import javax.xml.ws.Endpoint; @Configuration
public class WebServiceConfig { @Bean//发布服务名称,可以访问该路径查看拥有的webservice
public ServletRegistrationBean dispathcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/service/*");
} @Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
} @Bean
public PayWebService payWebService() {
return new PayWebServiceImpl();
} /**
* 绑定接口类,描述接口实现方法,以及接口名称.如果有多个接口需要实现,可以添加多个该方法(设置方法名不同,发布路径不同即可)
* @return
*/
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), payWebService());
endpoint.publish("/ws");
return endpoint;
}
}

此时,我们输入http://ip:port/service,可以看到如下图所示内容。左侧马赛克为接口包含的方法,右侧为接口的描述,包括发布地址、wsdl和命名空间。

点击wsdl的路径,可以看到接口的详细描述。

springboot配置cxf的更多相关文章

  1. SpringBoot配置属性之Server

    SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...

  2. SpringBoot基础系列-SpringBoot配置

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9990680.html SpringBoot基础系列-SpringBoot配置 概述 属性 ...

  3. springboot上传文件 & 不配置虚拟路径访问服务器图片 & springboot配置日期的格式化方式 & Springboot配置日期转换器

    1.    Springboot上传文件 springboot的文件上传不用配置拦截器,其上传方法与SpringMVC一样 @RequestMapping("/uploadPicture&q ...

  4. springboot配置Druid数据源

    springboot配置druid数据源 Author:SimpleWu springboot整合篇 前言 对于数据访问层,无论是Sql还是NoSql,SpringBoot默认采用整合SpringDa ...

  5. springboot配置详解

    springboot配置详解 Author:SimpleWu properteis文件属性参考大全 springboot默认加载配置 SpringBoot使用两种全局的配置文件,全局配置文件可以对一些 ...

  6. SpringBoot 配置 Servlet、Filter、Listener

    SpringBoot 配置 Servlet.Filter.Listener 在SpringBoot应用中,嵌入式的 Servlet 3.0+ 容器不会直接使用 ServletContainerInit ...

  7. SpringBoot 配置静态资源映射

    SpringBoot 配置静态资源映射 (嵌入式servlet容器)先决知识 request.getSession().getServletContext().getRealPath("/& ...

  8. springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息

    1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...

  9. SpringBoot配置(2) slf4j&logback

    SpringBoot配置(2) slf4j&logback 一.SpringBoot的日志使用 全局常规设置(格式.路径.级别) SpringBoot能自动适配所有的日志,而且底层使用slf4 ...

随机推荐

  1. Java正则表达式使用 | 叠加

    public class Test { public static void main(String[] args) { String s = "ni\nhao\nma he yi\nyon ...

  2. spring boot中的jave注解学习

    在spring中,不仅框架作者会使用java注解,开发者也常使用. 可以随手给个例子:在org.springframework.boot.autoconfigure.jdbc.DataSourcePr ...

  3. 写jquery插件(转载)

    如今做web开发,jquery 几乎是必不可少的,就连vs神器在2010版本开始将Jquery 及ui 内置web项目里了.至于使用jquery好处这里就不再赘述了,用过的都知道.今天我们来讨论下jq ...

  4. Redis 教程 Java工程师学习知识点

    1. Redis简介及安装 1.1 Redis 简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis 与其他 key - value 缓存产品有以下 ...

  5. NYOJ - 矩形嵌套(经典dp)

    矩形嵌套时间限制:3000 ms | 内存限制:65535 KB 描述 有n个矩形,每个矩形可以用a,b来描述,表示长和宽.矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当a<c,b< ...

  6. 四、XML语言学习(1)

    XML语言 1.XML是什么?XML是指可扩展标记语言XML是指可扩展标记语言(eXtensible Markup Language),它是一种标记语言,很类似HTML.它被设计的宗旨是传输数据,而非 ...

  7. org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password:

    tationProcessor' to allow for resolving potential circular referencesDEBUG 2018-05-28 11:32:35,016 o ...

  8. Java编程基础篇第五章

    数组概述 概念:数组是存储同一种数据类型多个元素的集合.也可以看成是一个容器.数组既可以存储基本数据类型,也可以存储引用数据类型.应用场景:为了存储同种数据类型的多个值 数组定义格式 格式1:元素类型 ...

  9. TX2-入门坑点-Ubuntu16.04任务栏消失

    问题:安装cuda过程中出现任务栏消失,快捷键失效的现象. 解决方法:重装桌面无法解决,使用cssm无法解决,最后删除home目录下的 .cache文件夹重启后解决

  10. Ubuntu软件安装和查看已安装相关知识

    说明:由于图形化界面方法(如Add/Remove... 和Synaptic Package Manageer)比较简单,所以这里主要总结在终端通过命令行方式进行的软件包安装.卸载和删除的方法.一.Ub ...