Skip to content
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

一个tomcat下部署多个war,导致app.id相同 #2921

Closed
chaos08 opened this issue Feb 9, 2020 · 9 comments
Closed

一个tomcat下部署多个war,导致app.id相同 #2921

chaos08 opened this issue Feb 9, 2020 · 9 comments
Labels

Comments

@chaos08
Copy link

chaos08 commented Feb 9, 2020

2020-02-09 15:26:39.244 [main] INFO com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider 85 initAppId - App ID is set to [....] by app.id property from System Property
两个应用都被System Property设置成其中一个应用的app.id,之前是使用application.yml的方式配置的app.id,看了文档说这种方式不适用于一个tomcat下多个war,已经改成app.properties,但是app.id仍然没有修改过来,请教

@nobodyiam
Copy link
Member

可以看下environment中的property sources,里面应该有app.id

@chaos08
Copy link
Author

chaos08 commented Feb 10, 2020

可以看下environment中的property sources,里面应该有app.id

不好意思,这个environment是指环境变量么,在里面没有找到。
下面的图里面也没有
image

@g5niusx
Copy link

g5niusx commented Feb 10, 2020

应该是让你看一下 spring 的 environment 对象。里面的 property sources 是存储我们配置的 propeties的。这个需要你debug看一下了,或者把它输出到日志里面。

@chaos08
Copy link
Author

chaos08 commented Feb 10, 2020

应该是让你看一下 spring 的 environment 对象。里面的 property sources 是存储我们配置的 propeties的。这个需要你debug看一下了,或者把它输出到日志里面。

非常感谢,我在日志里面输出了所有的System Property,发现确实有app.id这个Property,但是我并没有设置这个,不知道这个来源是哪。。
image
image

@g5niusx
Copy link

g5niusx commented Feb 10, 2020

这个就是你配置的app.properites文件来注入进去的,当然通过系统环境变量、-D app.id=xx这些都可以注入进去,主要看你使用的场景。看你说同一个tomcat部署来多个war,你看一下是不是tomcat注入了一个全局的 app.id,有可能你们配置了tomcat的 catalina.properties 里面的 shared.loader 。当然也有其他的可能性。。

@nobodyiam
Copy link
Member

@chaos08

你先看下 com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer#fillSystemPropertyFromEnvironment 这个逻辑

@stale
Copy link

stale bot commented Apr 15, 2020

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in 14 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 15, 2020
@stale
Copy link

stale bot commented Apr 29, 2020

This issue has been automatically closed because it has not had activity in the last 14 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Apr 29, 2020
@qixiaobo
Copy link

The same problem meet with sofa-ark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants