项目使用到SpringBoot整合cxf,为了在Linux服务器上运行,在idea中调试完毕后,通过maven打jar包,上传到服务器运行。
然而,每次打完jar包运行之后,总有如下报错:
org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered." 找了很多博客,都没有解决问题,常见的博客解决手段:
1.SpringBoot和cxf依赖版本冲突,换版本号
然而跟着别人的版本号换了n次,仍然报错。
2.修改maven plugin配置
好吧,maven我承认我还没完全学明白,总之改完dont work。
3.maven打包方式
有人说直接在命令行使用 mvn clean package -DSkipTests的,同样打完包还是dont work。
最终解决是在快要放弃的最后一次尝试,参考了博客
https://blog.csdn.net/qq_36256697/article/details/101348656
使用Build进行打包
(1)进入idea的Project Structure
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories (2)选择Artifacts,点击上方+号,选择JAR,右边出来选项选择 From modules with dependencies
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 这里会有一个jar包输出目录,默认是下图这样的,也可以自己修改。
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories (3)选择SpringBoot主类作为Main Class,
下面Jar files from libraries选择 copy to the output directory and link via manifest,
Directory for META-INF/MANIFEST.MF一定要选择你项目的src目录!
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 完成之后点击ok,关闭project structrue
(4)菜单栏选择Build->Build Artifacts...
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 点击Build,会打包输出到前面提到的jar包输出目录下。
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 最后进入到目录下可以看到有很多依赖jar包,以及自己的项目jar包,下面标红的是我的项目jar包。
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 在程序运行环境下执行 java -jar webservicedemo.jar,输出如下,报错消失。
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 可以看到我的两个webservice接口已经正常注册
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 题外话:
期间使用maven打包运行jar的时候还遇到了这个错
java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 我的做法是找到项目依赖的spring-boot-autoconfigure包下的META-INF/spring.factories
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 打开这个文件,找到里面这一段,全部copy下来
SpringBoot整合cxf jar包运行报错 完美解决org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered."java -jar 启动错误 No auto configuration classes found in META-INF/spring.factories 然后用360压缩打开我们maven生成的工程jar包,打开META-INF/spring.factories,将上面复制的这一段添加到文件最后。
这个报错的原因应该是maven打包的问题,至于到底由什么导致,百度搜寻也没有发现,只能用这种笨办法能暂时解决这个报错。。。