java
weixin_48965172
这个作者很懒,什么都没留下…
展开
-
listener中@Autowired无法注入bean
背景:使用监听器处理业务,需要使用自己的service方法; 错误:使用@Autowired注入service对象,最终得到的为null; 原因:listener、fitter都不是Spring容器管理的,无法在这些类中直接使用Spring注解的方式来注入我们需要的对象。 解决:写一个bean工厂,从spring的上下文WebApplicationContext 中获取。 import org.springframework.beans.BeansException; import org.springfr原创 2021-12-28 15:39:03 · 415 阅读 · 0 评论 -
Java根据图片提取文字
安装tesseract-ocr 地址:https://digi.bib.uni-mannheim.de/tesseract/ 添加环境变量: 在path中添加安装的目录路径如图: 测试: Java代码: import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web原创 2021-10-09 10:08:29 · 569 阅读 · 0 评论