CXF環境搭建網上的帖子大致相同,參考:
https://blog.csdn.net/maple_fix/article/details/79884320
遇到的問題,啓動項目報以下錯誤:
***************************
APPLICATION FAILED TO START
***************************
Description:
Method servletEndpointRegistrar in org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider' that could not be found.
- Bean method 'mainDispatcherServletPathProvider' not loaded because Default DispatcherServlet found non dispatcher servlet bean dispatcherServlet
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider' in your configuration.
經查閱資料找到 解決辦法,參考博客https://blog.csdn.net/qq_37394874/article/details/86523678:
將spring boot 版本換成 2.0.1RELEASE
<!-- spring boot 基礎依賴包 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>2.0.3.RELEASE</version> 使用此版本,集成webservice時啓動報錯,所以改爲使用2.0.1版本-->
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
cxf jar包使用以下兩個版本都可以:
<!-- cxf依賴 3.1.12 START-->
<!-- <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.12</version>
</dependency>
<!-- cxf依賴 3.1.12 END-->
-->
<!-- CXF 3.2.4 START-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
<!-- CXF 3.2.4 END-->
至此,問題解決了:
訪問如下地址也能正確看到wsdl
http://localhost:8081/dc/webservice/user?wsdl