Error creating bean with name ‘endpoint‘ defined in class path resource [.../CxfConfig.class]
Spring boot項目整合webservice后,引入阿里云短信包,項目啟動報錯。
問題描述:
最近一個老項目發送短信的接口需要由網易換成阿里云的,本來其它項目引入都沒什么問題,但這個項目之前使用cxf整合過webservice,導入阿里的jar包后,項目啟動報錯
Error creating bean with name ‘endpoint’ defined in class path resource [ct/edu/lms/web/server/config/CxfConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.ws.Endpoint]: Factory method ‘endpoint’ threw exception; nested exception is javax.xml.ws.WebServiceException:
完整截圖:
引入的包:
原因分析、解決:
報錯大概是因為cxf包和阿里云的包中某個xml解析包沖突了,其中有個com.sun.xml.bind是阿里云中的,于是嘗試使用exclusions去掉不想要的包,項目啟動正常。代碼如下:
<!-- 阿里云短信 --><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId><version>4.1.0</version><exclusions><exclusion><groupId>com.sun.xml.bind</groupId><artifactId>jaxb-core</artifactId></exclusion><exclusion><groupId>com.sun.xml.bind</groupId><artifactId>jaxb-impl</artifactId></exclusion> </exclusions></dependency>后續
本以為項目啟動不報錯就可以了,但短信發送不了!只能繼續找原因,到官網查看,發現官網的jar包已經升級到了4.5.3,嘗試引入,所有的問題都解決了。
<!-- 阿里云短信 --><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId><version>4.5.3</version></dependency>進入包中查看發現新版已經去掉com.sun.xml.bind這兩個包了,應該也是修復了相應的bug。
總結
糾結了大半天的問題,升級一下就解決了,還是需要仔細分析問題,從源頭找解決辦法,特此記錄一下。
總結
以上是生活随笔為你收集整理的Error creating bean with name ‘endpoint‘ defined in class path resource [.../CxfConfig.class]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS 自定义实现数字滚动处理
- 下一篇: 计算机网络实验报告双机互联,双机互联实验