SSM整合会遇到的坑

1.JDK版本问题,之前配置啥的都没错但是却出现

Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource 
[org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; 
nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

出现这个问题是:
上面的错误提示为nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException,
经查看是因为我的jdk版本不兼容,我当前的jdk版本为11。而引入的@enableAuthorizationServer在jdk8下可以完美运行,jdk11并没有兼容这个注解,因此会报这个错误。
解决方案
在这个项目的pom.xml中引入下面三个依赖解决jdk11的兼容问题

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.0-b170127.1453</version>
    </dependency>

小说明
此解决方案只适用于jdk版本不兼容产生的这个问题,如果不符合这个大前提,该解决方案不一定适用哦~
详情请看:https://blog.csdn.net/qq_37393900/article/details/103136461
下面是第二个坑:

2.文件重复加载问题

Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file : 
Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException

后面改了JDK的版本(从11改到了8)还是出现了这个问题(JDK版本8向对于来说更为稳定兼容性更好)
该问题解决方案为
先看看我的配置文件错误的点:
XML的文件(图一)
在这里插入图片描述
spring.XML文件(图二)
在这里插入图片描述
图三
在这里插入图片描述
我猜测应该是文件重复加载的问题然后我就将图二的扫描全部mapper.XML的文件注掉然后就运行成功了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值