为什么after会在afterReturn之前?
老师,你好,为什么本节视频的after会在afterReturn之前?参考本节(5-5)的05:08(5分08秒)处。
而上节视频的after会在afterReturn之后,参考上节(5-4)的13:36(13分36秒)处。
老师,你好,为什么本节视频的after会在afterReturn之前?参考本节(5-5)的05:08(5分08秒)处。
而上节视频的after会在afterReturn之后,参考上节(5-4)的13:36(13分36秒)处。
2016-07-23
Spring官方的说法是,在同一个切面内,同类型(前/后)的通知顺序是不确定的。因为通过反射确定类中生命(这句话的意思,我也不理解)。
见官方文档说明(同时给出了排序的建议):
When two pieces of advice defined in the same aspect both need to run at the same join point, the ordering is undefined (since there is no way to retrieve the declaration order via reflection for javac-compiled classes). Consider collapsing such advice methods into one advice method per join point in each aspect class, or refactor the pieces of advice into separate aspect classes - which can be ordered at the aspect level.
举报