Idea+StringBoot+cxf

来源:互联网 发布:reflower for mac 编辑:程序博客网 时间:2024/06/01 07:48

StringBoot项目,maven 项目管理,

1.首先需要加入如下的pom

<!-- CXF Start 3.1.6--><dependency>    <groupId>org.apache.cxf</groupId>    <artifactId>cxf-rt-frontend-jaxws</artifactId>    <version>2.5.1</version></dependency><dependency>    <groupId>org.apache.cxf</groupId>    <artifactId>cxf-rt-transports-http</artifactId>    <version>2.5.1</version></dependency><!-- CXF END-->

由于我调用的是Oracle的一个webservice框架,版本较老,所以只能用2.5.1版本的cxf。

@Beanpublic ServletRegistrationBean dispatcherServlet() {    return new ServletRegistrationBean(new CXFServlet(), "/soap/*");}@Bean(name = Bus.DEFAULT_BUS_ID)public SpringBus springBus() {    return new SpringBus();}/** 接口注入* */@Beanpublic User user() {    return new UserImpl();}/** 发布接口* */@Beanpublic Endpoint endpoint() {    EndpointImpl endpoint = new EndpointImpl(springBus(), user());    endpoint.publish("/user");    return endpoint;}
2.Application中加入以上代码
运行即可发布成功,输入http://localhost:8080/soap/测试下是否成功。

原创粉丝点击