-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix]设置在web环境下才注入拦截器 #1029
[fix]设置在web环境下才注入拦截器 #1029
Conversation
@@ -35,6 +36,7 @@ | |||
* And clean up Seata information after servlet method invocation in | |||
* {@link org.springframework.web.servlet.HandlerInterceptor#afterCompletion(HttpServletRequest, HttpServletResponse, Object, Exception)} | |||
*/ | |||
@ConditionalOnWebApplication | |||
public class SeataHandlerInterceptor implements HandlerInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems no need to add it on SeataHandlerInterceptor
, on SeataHandlerInterceptorConfiguration
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
似乎无需在上添加它
SeataHandlerInterceptor
,就SeataHandlerInterceptorConfiguration
足够了。
是的,我当时没有仔细看spring.factories
文件的配置
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我不是很清楚其他容器是怎么工作的,但是这个限制是必须的至少在servlet
容器下是这样的
@@ -23,6 +23,7 @@ | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means unused, remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经删除了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我先仔细阅读下------------------ 原始邮件 ------------------
发件人: "format"<[email protected]>
发送时间: 2019年11月1日(星期五) 下午4:56
收件人: "alibaba/spring-cloud-alibaba"<[email protected]>;
抄送: "赵云兴"<[email protected]>;"Author"<[email protected]>;
主题: Re: [alibaba/spring-cloud-alibaba] [fix]设置在web环境下才注入拦截器 (#1029)
@fangjian0423 commented on this pull request.
In spring-cloud-alibaba-seata/src/main/java/com/alibaba/cloud/seata/web/SeataHandlerInterceptor.java:
@@ -23,6 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import 顺序不对。 你参看以下如何贡献(使用插件格式化一下代码): https://github.com/alibaba/spring-cloud-alibaba/wiki/%E5%A6%82%E4%BD%95%E8%B4%A1%E7%8C%AE%E4%BB%A3%E7%A0%81#%E9%85%8D%E7%BD%AE-spring-cloud-%E6%A0%87%E5%87%86%E7%9A%84%E4%BB%A3%E7%A0%81%E6%A0%BC%E5%BC%8F
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
建议撤销无效的 commit 提交,只需一个 commit 记录即可。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[fix]设置在web环境下才注入拦截器
Describe what this PR does / why we need it
com.alibaba.cloud.seata.web.SeataHandlerInterceptor
和com.alibaba.cloud.seata.web.SeataHandlerInterceptorConfiguration
在web环境下才工作的,但是果然环境仅依赖spring-boot-starter
的时候就出现异常了或者容器用的不是servlet
容器的话也是出现问题的,所以我添加了条件判断