springboot日常问题处理手记
springboot启动问题
1.@Autowired报错Could not autowire. No beans of xxx
解决:只需在DAO接口加上@Component 或者 @Repository
参考:https://blog.csdn.net/Mr_EvanChen/article/details/84035445
2.Consider defining a bean of type ‘XXX’ in your configuration.
解决:在启动类上加上@MapperScan或者@ComponentScan注解,手动指定application类要扫描哪些包下的注解,如下所示:
@SpringBootApplication @ComponentScan(basePackages = {"com.xxx.xxx.dao"})
参考:https://www.cnblogs.com/nananana/p/9333917.html
https://blog.csdn.net/suxiexingchen/article/details/84984349
3.Failed to configure a DataSource: 'url' attribute is not specified and no embedd
问题:应用中没有配置datasource的一些相关属性,例如:地址值啊,数据库驱动啊,用户名啊,密码啊
解决:application.properties文件中加spring.datasource相关配置
参考:https://blog.csdn.net/qq_40223688/article/details/88191732
4.org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException
问题:之前生成了引起异常的队列,一启动就报错
解决:浏览器打开http://192.168.0.100:15672/#/把之前相关的队列删除,再次启动不报错了
参考:https://www.cnblogs.com/javawxid/p/10855071.html
5.Exception in thread "main" java.lang.NoSuchMethodError: freemarker.template.Configuration.
定位是freemarker版本问题:
1 2 3 4 5 | <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.20</version> </dependency> |
改为:
1 2 3 4 5 | <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.28</version> </dependency> |
就正常了
springboot运行中问题
1.mybatis-plus驼峰下划线转换问题
设置不用其下划线命名法,在MybatisPlusConfig.java中设置
1 2 | MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean(); mybatisPlus.setDbColumnUnderline( true ); |
也可以在application.yml配置
1 2 3 4 | mybatis-plus: global-config: #驼峰下划线转换 db-column-underline: true |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!