使用mybatis-plus操作entity实体类时项目启动失败(已解决)

Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.3.8.RELEASE.jar:2.3.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.8.RELEASE.jar:2.3.8.RELEASE]
    a

---------------------------------------------------------------------------------------------------------------------------------

解决方法:

错误日志显示了 Spring Boot 应用程序启动失败的详细信息,主要问题在于无法启动内嵌的 Tomcat 服务器,并且抛出了 BeanCreationException 异常。异常的根源在于 jwtAuthenticationFilter 这个 bean 的创建过程中出现了问题,具体是因为 UserCompetitionRemark 实体类在使用 MyBatis Plus 时配置有误。

根据异常信息,以下是主要的问题和建议的解决步骤:

  1. @TableId 注解问题com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: @TableId can't more than one in Class: "com.kjw.entity.UserCompetitionRemark" 这个异常表明 UserCompetitionRemark 类中使用了多个 @TableId 注解,但 MyBatis Plus 要求一个实体类只能有一个字段使用 @TableId 注解来标记主键。

  2. 检查实体类:你需要检查 com.kjw.entity.UserCompetitionRemark 实体类,确保只有一个字段使用了 @TableId 注解。

  3. 检查 MyBatis Plus 配置:如果 UserCompetitionRemark 实体类使用了 XML 映射文件,确保该文件的路径正确,并且没有语法错误。

  4. 检查 SQLSessionFactory 配置:异常信息中提到了 sqlSessionFactory 的创建失败,这通常与 MyBatis Plus 的配置有关。检查 MybatisPlusAutoConfiguration 中的相关配置是否正确。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值