Error creating bean with name ‘org.apache.cxf.jaxws.spring.NamespaceHandler$SpringServerFactoryBean

本文记录了在Spring框架整合JAX-WS过程中遇到的一个关于文件无法注入容器的问题及解决办法。通过增加缺失的HTTP传输相关依赖解决了问题。

问题描述

我是在spring整合jaxws 使用webservice的时候报错的。
在这里插入图片描述

解决过程

这个问题说实话卡了我很久,一直没找着原因,其实但看这个报错就能看出来,有个文件注入不了容器,我一直以为是配置问题,修改了很多配置,什么原因都想到了,唯一没想到的就是缺少依赖。

我只引入了这一个依赖:

		<!-- CXF WS开发  -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.0.1</version>
			<scope>compile</scope>
        </dependency>

从包里面能看出来确实有这个包,但是就是报错。

最后加上这个依赖就好啦

<dependency>
	<groupId>org.apache.cxf</groupId>
	<artifactId>cxf-rt-transports-http</artifactId>
	<version>3.0.1</version>
	<scope>compile</scope>
</dependency>

总结

对于这些不常用的框架,一旦报错,网上能解答的确实很少,长记性了,以后遇到bean注入不了的时候一定要先确保依赖引入正确,再考虑从代码上找错误,可以避免少走弯路。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceEndpoint' defined in class path resource [port/CxfConfig.class]: Failed to instantiate [jakarta.xml.ws.Endpoint]: Factory method 'userServiceEndpoint' threw exception with message: jakarta.xml.ws.WebServiceException: Could not load Webservice SEI at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1355) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1185) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971) ~[spring-context-6.1.14.jar:6.1.14] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625) ~[spring-context-6.1.14.jar:6.1.14] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.5.jar:3.3.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.5.jar:3.3.5] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.5.jar:3.3.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.5.jar:3.3.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.5.jar:3.3.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.5.jar:3.3.5] at port.PortTestApplication.main(PortTestApplication.java:10) ~[classes/:na] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [jakarta.xml.ws.Endpoint]: Factory method 'userServiceEndpoint' threw exception with message: jakarta.xml.ws.WebServiceException: Could not load Webservice SEI at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178) ~[spring-beans-6.1.14.jar:6.1.14] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.14.jar:6.1.14] ... 19 common frames omitted Caused by: jakarta.xml.ws.WebServiceException: jakarta.xml.ws.WebServiceException: Could not load Webservice SEI at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:373) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] at port.CxfConfig.userServiceEndpoint(CxfConfig.java:22) ~[classes/:na] at port.CxfConfig$$SpringCGLIB$$0.CGLIB$userServiceEndpoint$0(<generated>) ~[classes/:na] at port.CxfConfig$$SpringCGLIB$$FastClass$$1.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.14.jar:6.1.14] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:348) ~[spring-context-6.1.14.jar:6.1.14] at port.CxfConfig$$SpringCGLIB$$0.userServiceEndpoint(<generated>) ~[classes/:na] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146) ~[spring-beans-6.1.14.jar:6.1.14] ... 20 common frames omitted Caused by: jakarta.xml.ws.WebServiceException: Could not load Webservice SEI at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.initialize(JaxWsImplementorInfo.java:301) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.<init>(JaxWsImplementorInfo.java:60) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:401) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:336) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] ... 30 common frames omitted Caused by: java.lang.ClassNotFoundException: com.example.demo.UserService at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na] at org.apache.cxf.common.classloader.ClassLoaderUtils.loadClass2(ClassLoaderUtils.java:319) ~[cxf-core-4.1.1.jar:4.1.1] at org.apache.cxf.common.classloader.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:279) ~[cxf-core-4.1.1.jar:4.1.1] at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.initialize(JaxWsImplementorInfo.java:299) ~[cxf-rt-frontend-jaxws-4.1.1.jar:4.1.1] ... 33 common frames omitted
06-28
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.15</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.hzxy</groupId> <artifactId>AssistCase_GA</artifactId> <version>0.0.2-SNAPSHOT</version> <name>PublicSecurityAssistCase</name> <!--<packaging>war</packaging>--> <description>Demo project for Spring Boot</description> <!-- <properties>--> <!-- <java.version>1.8</java.version>--> <!-- <hutool.version>5.4.4</hutool.version>--> <!-- </properties>--> <properties> <java.version>17</java.version> <hutool.version>5.4.4</hutool.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> <version>3.2.5</version> <exclusions> <exclusion> <artifactId>cxf-core</artifactId> <groupId>org.apache.cxf</groupId> </exclusion> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>spring-boot-starter-web</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>spring-boot</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>com.liferay</groupId> <artifactId>org.apache.commons.configuration</artifactId> <version>1.10.LIFERAY-PATCHED-2</version> </dependency> <!-- axis 1.4 jar start --> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId> <version>0.2</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis-jaxrpc</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis-saaj</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.4</version> </dependency> <!-- axis 1.4 jar end --> <!--lib--> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-tomcat</artifactId>--> <!--<scope>provided</scope>--> <!--</dependency>--> <!--<dependency>--> <!--<groupId>javax.servlet</groupId>--> <!--<artifactId>javax.servlet-api</artifactId>--> <!--<version>3.0.1</version>--> <!--<scope>provided</scope>--> <!--</dependency>--> <dependency> <groupId>com.hzxy.framework</groupId> <artifactId>common</artifactId> <version>0.0.54-SNAPSHOT</version> <exclusions> <exclusion> <artifactId>springfox-swagger-ui</artifactId> <groupId>io.springfox</groupId> </exclusion> <exclusion> <artifactId>spring-boot-starter-web</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>lombok</artifactId> <groupId>org.projectlombok</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.hzxy.framework</groupId> <artifactId>office_nmga</artifactId> <version>0.0.17-SNAPSHOT</version> <exclusions> <exclusion> <artifactId>springfox-swagger-ui</artifactId> <groupId>io.springfox</groupId> </exclusion> <exclusion> <artifactId>spring-boot-starter-web</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>lombok</artifactId> <groupId>org.projectlombok</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.hzxy.framework</groupId> <artifactId>multipleStorageTools_GA</artifactId> <version>0.0.5-SNAPSHOT</version> </dependency> <dependency> <groupId>io.dgraph</groupId> <artifactId>dgraph4j</artifactId> <version>20.03.3</version> <exclusions> <exclusion> <artifactId>guava</artifactId> <groupId>com.google.guava</groupId> </exclusion> <exclusion> <artifactId>netty-handler</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>netty-common</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>grpc-protobuf</artifactId> <groupId>io.grpc</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.org</groupId> <artifactId>dom4j</artifactId> <version>2.1.3</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/dom4j-2.1.3.jar</systemPath> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20170516</version> </dependency> <dependency> <groupId>xom</groupId> <artifactId>xom</artifactId> <version>1.2.5</version> <exclusions> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> <exclusion> <artifactId>xercesImpl</artifactId> <groupId>xerces</groupId> </exclusion> <exclusion> <artifactId>xalan</artifactId> <groupId>xalan</groupId> </exclusion> </exclusions> </dependency> <!-- <dependency> <groupId>com.hzxy</groupId> <artifactId>instantmsg</artifactId> <scope>system</scope> <version>0.0.1-SNAPSHOT</version> <systemPath>${project.basedir}/src/main/resources/lib/instantmsg-0.0.1-SNAPSHOT.jar</systemPath> </dependency> --> <!--Swagger2--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> <exclusion> <artifactId>guava</artifactId> <groupId>com.google.guava</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.5.21</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.10.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.5.15</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> <exclusions> <exclusion> <artifactId>mybatis</artifactId> <groupId>org.mybatis</groupId> </exclusion> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.21</version> <exclusions> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId> <version>5.1.1</version> <exclusions> <exclusion> <artifactId>guava</artifactId> <groupId>com.google.guava</groupId> </exclusion> <exclusion> <artifactId>netty-handler</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>netty-common</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>json-path</artifactId> <groupId>com.jayway.jsonpath</groupId> </exclusion> </exclusions> </dependency> <!-- 使用druid连接池需要加dbcp依赖 --> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-dbcp</artifactId> <version>10.0.16</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.1</version> <exclusions> <exclusion> <artifactId>mybatis-plus</artifactId> <groupId>com.baomidou</groupId> </exclusion> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <!-- mybatis plus 代码生成器依赖 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.4.1</version> </dependency> <!-- 代码生成器模板 --> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>2.5.15</version> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> <exclusion> <artifactId>json-path</artifactId> <groupId>com.jayway.jsonpath</groupId> </exclusion> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>spring-boot</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.1.6</version> </dependency> <dependency> <groupId>com.auth0</groupId> <artifactId>java-jwt</artifactId> <version>2.2.0</version> </dependency> <!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib --> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> <exclusions> <exclusion> <artifactId>commons-beanutils</artifactId> <groupId>commons-beanutils</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.54</version> </dependency> <!--<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency>--> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> <exclusions> <exclusion> <artifactId>commons-compress</artifactId> <groupId>org.apache.commons</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>2.2.7</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>net.coobird</groupId> <artifactId>thumbnailator</artifactId> <version>0.4.8</version> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>7.17.23</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-elasticsearch</artifactId> <version>3.2.5.RELEASE</version> <exclusions> <exclusion> <artifactId>netty-handler</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>netty-common</artifactId> <groupId>io.netty</groupId> </exclusion> <exclusion> <artifactId>elasticsearch</artifactId> <groupId>org.elasticsearch</groupId> </exclusion> <exclusion> <artifactId>elasticsearch-core</artifactId> <groupId>org.elasticsearch</groupId> </exclusion> <exclusion> <artifactId>joda-time</artifactId> <groupId>joda-time</groupId> </exclusion> </exclusions> </dependency> <!-- rabbit mq --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> <version>2.5.15</version> <exclusions> <exclusion> <artifactId>spring-amqp</artifactId> <groupId>org.springframework.amqp</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>${hutool.version}</version> </dependency> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.10.11</version> </dependency> <dependency> <groupId>com.dm</groupId> <artifactId>Dm8JdbcDriver</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/DmJdbcDriver18.jar</systemPath> </dependency> <dependency> <groupId>org.apache.pdfbox</groupId> <artifactId>pdfbox</artifactId> <version>2.0.24</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-jexl</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>org.icepdf.os</groupId> <artifactId>icepdf-core</artifactId> <version>6.2.2</version> <exclusions> <exclusion> <groupId>javax.media</groupId> <artifactId>jai_core</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-pdfa</artifactId> <version>5.5.13</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> <!-- pdf样式 --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> <!--pdf相关操作--> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.10</version> </dependency> <dependency> <groupId>com.drewnoakes</groupId> <artifactId>metadata-extractor</artifactId> <version>2.14.0</version> </dependency> <!-- <dependency>--> <!-- <groupId>org.springframework</groupId>--> <!-- <artifactId>spring-test</artifactId>--> <!-- <version>RELEASE</version>--> <!-- </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.5.15</version> <exclusions> <exclusion> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> </exclusion> <exclusion> <artifactId>spring-data-elasticsearch</artifactId> <groupId>org.springframework.data</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>x-pack-transport</artifactId> <version>6.8.16</version> </dependency> <dependency> <groupId>uk.com.robust-it</groupId> <artifactId>cloning</artifactId> <version>1.9.12</version> </dependency> <dependency> <groupId>com.aspose.words</groupId> <artifactId>aspose</artifactId> <version>15.8.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/aspose-words-15.8.0-jdk16.jar</systemPath> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.5.15</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot</artifactId> <version>2.5.15</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-autoconfigure</artifactId> <version>2.5.15</version> <exclusions> <exclusion> <artifactId>spring-boot</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.3.29</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.3.29</version> <exclusions> <exclusion> <artifactId>spring-beans</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-messaging</artifactId> <version>5.3.29</version> <exclusions> <exclusion> <artifactId>spring-beans</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>5.3.29</version> <exclusions> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>6.1.13</version> <exclusions> <exclusion> <artifactId>spring-beans</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>spring-expression</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>spring-web</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>5.3.39</version> <exclusions> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.5.3.1</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>1.53.0</version> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.5.0</version> <exclusions> <exclusion> <artifactId>spring-boot-autoconfigure</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <exclusion> <artifactId>spring-webmvc</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>32.0.0-android</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.4</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> <version>1.26.0</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.6</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.2</version> </dependency> <dependency> <groupId>xalan</groupId> <artifactId>xalan</artifactId> <version>2.7.3</version> </dependency> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-amqp</artifactId> <version>2.2.20.RELEASE</version> <exclusions> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-core</artifactId> <version>3.5.8</version> </dependency> <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-common</artifactId> <version>4.1.116.Final</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-handler</artifactId> <version>4.1.100.Final</version> <exclusions> <exclusion> <artifactId>netty-common</artifactId> <groupId>io.netty</groupId> </exclusion> </exclusions> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>com.fasterxml.jackson</groupId> <artifactId>jackson-bom</artifactId> <version>2.13.5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <repositories> <!-- add the elasticsearch repo --> <!-- 必须加上 这个仓库,不然x-pack-transport6.8.6在其他仓库中没有--> <repository> <id>elasticsearch-releases</id> <url>https://artifacts.elastic.co/maven</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <distributionManagement> <repository> <id>nexus-releases</id> <name>Local Nexus Repository</name> <url>http://192.168.3.102:8082/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Local Nexus Repository</name> <url>http://192.168.3.102:8082/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> <build> <plugins> <!--如果是打jar包,则需在build的plugins中添加如下配置--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.15</version> <configuration> <!--值为true是指打包时包含scope为system的第三方Jar包--> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> <!--<plugins>--> <!--<plugin>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-maven-plugin</artifactId>--> <!--</plugin>--> <!--<plugin>--> <!--<groupId>org.apache.maven.plugins</groupId>--> <!--<artifactId>maven-compiler-plugin</artifactId>--> <!--<version>${maven-compiler-plugin.version}</version>--> <!--<configuration>--> <!--<source>1.8</source>--> <!--<target>1.8</target>--> <!--<skip>true</skip>--> <!--<encoding>UTF-8</encoding>--> <!--<compilerArguments>--> <!--<extdirs>${project.basedir}/src/main/resources/lib</extdirs>--> <!--<!–extdirs>lib</extdirs>–>--> <!--</compilerArguments>--> <!--</configuration>--> <!--</plugin>--> <!--<plugin>--> <!--<groupId>org.apache.maven.plugins</groupId>--> <!--<artifactId>maven-war-plugin</artifactId>--> <!--<version>3.1.0</version>--> <!--<configuration>--> <!--<webResources>--> <!--<resource>--> <!--<directory>src/main/resources/lib/</directory>--> <!--<targetPath>WEB-INF/lib/</targetPath>--> <!--<includes>--> <!--<include>**/*.jar</include>--> <!--</includes>--> <!--</resource>--> <!--</webResources>--> <!--<failOnMissingWebXml>false</failOnMissingWebXml>--> <!--</configuration>--> <!--</plugin>--> <!--</plugins>--> </build> </project> 上述是我项目的pom文件启动报错 Error creating bean with name 'catalogueOcrTimer' defined in file [D:\work\nmGA_DB\Code\back\PublicSecurityAssistCase_back\target\classes\com\hzxy\PublicSecurityAssistCase\Timer\CatalogueOcrTimer.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabAutoCatalogueTaskServiceImpl': Unsatisfied dependency expressed through field 'autoCatalogueService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autoCatalogueService': Unsatisfied dependency expressed through field 'tabTrailProcessOperateCompleteService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabTrailProcessOperateCompleteServiceImpl': Unsatisfied dependency expressed through field 'tabCaseFolderTreeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseFolderTreeServiceImpl': Unsatisfied dependency expressed through field 'tabCaseFolderTemplateTreeServiceImpl'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseFolderTemplateTreeServiceImpl': Unsatisfied dependency expressed through field 'tabCaseXsshFolderResultService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseXsshFolderResultServiceImpl': Unsatisfied dependency expressed through field 'tabCaseService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseServiceImpl': Unsatisfied dependency expressed through field 'tabCaseStatisticsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseStatisticsServiceImpl': Unsatisfied dependency expressed through field 'elasticSearchService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchServiceImpl' defined in file [D:\work\nmGA_DB\Code\back\PublicSecurityAssistCase_back\target\classes\com\hzxy\PublicSecurityAssistCase\service\es\Impl\ElasticsearchServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/hzxy/PublicSecurityAssistCase/config/ElasticsearchConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/ToXContentObject Error creating bean with name 'tabAutoCatalogueTaskServiceImpl': Unsatisfied dependency expressed through field 'autoCatalogueService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autoCatalogueService': Unsatisfied dependency expressed through field 'tabTrailProcessOperateCompleteService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabTrailProcessOperateCompleteServiceImpl': Unsatisfied dependency expressed through field 'tabCaseFolderTreeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseFolderTreeServiceImpl': Unsatisfied dependency expressed through field 'tabCaseFolderTemplateTreeServiceImpl'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseFolderTemplateTreeServiceImpl': Unsatisfied dependency expressed through field 'tabCaseXsshFolderResultService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseXsshFolderResultServiceImpl': Unsatisfied dependency expressed through field 'tabCaseService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseServiceImpl': Unsatisfied dependency expressed through field 'tabCaseStatisticsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tabCaseStatisticsServiceImpl': Unsatisfied dependency expressed through field 'elasticSearchService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchServiceImpl' defined in file [D:\work\nmGA_DB\Code\back\PublicSecurityAssistCase_back\target\classes\com\hzxy\PublicSecurityAssistCase\service\es\Impl\ElasticsearchServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/hzxy/PublicSecurityAssistCase/config/ElasticsearchConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/ToXContentObject
最新发布
07-10
### 解决 `MessageModel` 类未找到的问题 当遇到 `ClassNotFoundException: org.apache.rocketmq.common.protocol.heartbeat.MessageModel` 错误时,这通常意味着 RocketMQ 的依赖项未能正确加载到项目的类路径中。 #### 1. 检查 Maven 或 Gradle 配置文件中的依赖关系 确保在项目的构建配置文件(pom.xml 对于 Maven, build.gradle 对于 Gradle)中有如下依赖声明: 对于 Maven 用户: ```xml <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-client</artifactId> <version>${rocketmq.version}</version> </dependency> ``` 对于 Gradle 用户: ```groovy implementation 'org.apache.rocketmq:rocketmq-client:${rocketmq.version}' ``` 其中 `${rocketmq.version}` 应替换为实际使用的版本号[^1]。 #### 2. 清理并重新编译项目 有时本地缓存可能会导致问题。尝试清理本地仓库缓存,并强制更新依赖库: - 使用命令 `mvn clean install -U` (Maven) - 或者执行 `gradlew clean build --refresh-dependencies` (Gradle) #### 3. 确认 RocketMQ 客户端 SDK 版本兼容性 不同版本之间可能存在 API 变更或移除某些功能的情况,请确认所使用的客户端 SDK 是否与服务器端保持一致,并查阅官方文档了解是否有任何已知的变化或建议升级至最新稳定版[^2]。 #### 4. 添加额外的依赖包 如果上述方法仍无法解决问题,则可能是因为缺少其他必要的组件。可以考虑增加以下依赖来获取完整的协议支持: ```xml <!-- For Maven --> <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-common</artifactId> <version>${rocketmq.version}</version> </dependency> // For Gradle implementation 'org.apache.rocketmq:rocketmq-common:${rocketmq.version}' ``` 通过以上措施应该能够有效解决因缺失 `MessageModel` 导致的错误情况。另外值得注意的是,在引入新的依赖之前最好先查看当前工程里已经存在的依赖列表以免造成冲突[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怪 咖@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值