问题原因:jar包损坏或者有其它问题
解决方案:删除损坏或有其它的jar包,然后重新导入
继续报错:
“Error:(7, 38) java: 无法访问org.springframework.stereotype.Component
错误的类文件: /D:/WorkingSoftwareInstall/maven/scarepository/org/springframework/spring-context/6.1.10/spring-context-6.1.10.jar!/org/springframework/stereotype/Component.class
类文件具有错误的版本 61.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。”
问题原因:springboot3.3.1版本和jdk1.8版本不兼容
解决方案:pom文件中修改parent版本为2.3.2
继续报错:
“Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
问题原因:mybatis plus使用错误的依赖如下
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.5.4</version> </dependency>
解决方案:mybatis plus改为正确的依赖如下
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.2</version> </dependency>
继续报错:
“org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.dao.UserDao.getUserById”
问题原因:mybatis plus不能使用自定义接口方法getUserById
解决方案:使用mybatis plus自带的方法selectById
继续报错:“Cause: java.sql.SQLSyntaxErrorException: Table 'xxxxxx.user' doesn't exist”
问题原因:默认使用domain中的User作为sql语句中的表名
解决方案:再domain中的User类上添加注解@TableName指定sql语句中的表名