You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java8+Spring5+SpringWS3项目启动报错:AnnotationActionEndpointMapping Bean创建失败

我之前也碰到过类似的Spring WS迁移踩坑问题,结合你用的Java 8 + Spring 5 + Spring WS 3 + Tomcat 8的环境,这个AnnotationActionEndpointMapping#0的创建失败通常和几个核心点有关,给你梳理下排查和解决方向:

排查与解决方案

1. 先搞定依赖版本冲突

Spring WS 3和Spring 5的兼容性是严格绑定的,从旧版本迁移最容易栽在这里:

  • 检查你的pom.xml(Maven)或build.gradle,确保所有Spring核心模块(context、beans、web等)都是和Spring WS 3匹配的5.x稳定版(比如Spring WS 3.0.x对应Spring 5.0.x,3.1.x对应Spring 5.1.x,以此类推)。
  • 用依赖分析命令揪出隐藏的旧版本依赖,比如Maven里执行:
    mvn dependency:tree | grep spring-
    
    如果发现有低版本Spring jar被间接引入,直接在对应依赖里加exclusions排除掉。

2. 检查XML配置的正确性

因为你用XML配置Web服务,AnnotationActionEndpointMapping的初始化完全依赖正确的配置:

  • 确保你的Spring WS配置文件里已经声明了<sws:annotation-driven/>标签——这个标签会自动注册AnnotationActionEndpointMapping等必要bean,手动配置很容易出错。如果是手动配置这个bean,检查是否漏了messageFactory、endpointAdapter这类关键属性的引用。
  • 给你个参考的正确配置片段:
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:sws="http://www.springframework.org/schema/web-services"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/web-services
               http://www.springframework.org/schema/web-services/web-services.xsd">
    
        <sws:annotation-driven/>
    
        <!-- 其他必要配置:消息工厂、端点映射器等 -->
    </beans>
    

3. 端点类的注解要合规

AnnotationActionEndpointMapping是专门处理带@Action注解的端点方法的,端点类出问题也会导致bean初始化失败:

  • 检查所有Web服务端点类,确保@Endpoint注解用对了,方法上的@Action注解是有效的URI格式,别写错了格式。
  • 把旧版本里的废弃WS注解替换成Spring WS 3的对应新注解,比如有些旧的@WebService相关注解已经不兼容了。

4. Tomcat 8的类加载坑要避开

Tomcat 8的类加载机制和旧容器不一样,容易和war包里的依赖冲突:

  • 检查你的war包是否打包了Tomcat已经提供的API(比如servlet-api、jsp-api),如果有,把这些依赖的scope设为provided,避免类加载冲突。
  • 示例Maven配置:
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    

5. 一定要看完整报错栈

你提供的报错信息被截断了(Instant...),完整的栈跟踪里会有具体的根因——比如是某个类找不到、方法不存在,还是属性注入失败。找到根因才能更快解决问题,比如如果是ClassNotFoundException,直接补对应依赖就行。

内容的提问来源于stack exchange,提问作者user260495

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:06:29