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 时配置有误。
根据异常信息,以下是主要的问题和建议的解决步骤:
-
@TableId 注解问题:
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: @TableId can't more than one in Class: "com.kjw.entity.UserCompetitionRemark"
这个异常表明UserCompetitionRemark
类中使用了多个@TableId
注解,但 MyBatis Plus 要求一个实体类只能有一个字段使用@TableId
注解来标记主键。 -
检查实体类:你需要检查
com.kjw.entity.UserCompetitionRemark
实体类,确保只有一个字段使用了@TableId
注解。 -
检查 MyBatis Plus 配置:如果
UserCompetitionRemark
实体类使用了 XML 映射文件,确保该文件的路径正确,并且没有语法错误。 -
检查 SQLSessionFactory 配置:异常信息中提到了
sqlSessionFactory
的创建失败,这通常与 MyBatis Plus 的配置有关。检查MybatisPlusAutoConfiguration
中的相关配置是否正确。