atjiu / pybbs

更实用的Java开发的社区(论坛),Better use of Java development community (forum)
GNU Affero General Public License v3.0
1.84k stars 706 forks source link

上次更新后,新增话题,es不自动增加索引? #94

Closed YANGJINJUE closed 5 years ago

YANGJINJUE commented 5 years ago

image 该切面并未执行? 上次更新后,新增话题,es不自动增加索引?

atjiu commented 5 years ago

确实没有执行。我在测试的时候 @Around 没有问题,然后 @After 的方法我就没测了。。 没想到还真出问题了

同样作为插件的 redis 缓存,@After 的方法都执行了,我再找找原因

YANGJINJUE commented 5 years ago

@Autowired private ApplicationContext applicationContext; private TopicService self; @PostConstruct private void init() { self = (TopicService) applicationContext.getBean("topicService"); }

// 索引话题 self.indexTopic(String.valueOf(topic.getId()), topic.getTitle(), topic.getContent()); 我在本地使用了一下这种方式可以的,参考(Spring AOP对嵌套方法不起作用):https://blog.csdn.net/bobozai86/article/details/78896487

atjiu commented 5 years ago

已经修复了 https://github.com/tomoya92/pybbs/commit/a67db288270214f68c3d84a9ba33fc909ea6842a

既然是嵌套调用的问题,那就把索引的service抽出来单独做为一个索引的服务类,我这提供了一个es的插件实现,别人也可以用solr来实现这个功能,就没有冲突了

这次我把redis跟es的切面方法都测了一下,已经没有问题了

最后:感谢提供的解决办法 :smile:

YANGJINJUE commented 5 years ago

ok。