apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
29.16k stars 10.2k forks source link

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

Closed chaos08 closed 4 years ago

chaos08 commented 4 years ago

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 commented 4 years ago

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

chaos08 commented 4 years ago

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

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

g5niusx commented 4 years ago

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

chaos08 commented 4 years ago

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

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

g5niusx commented 4 years ago

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

nobodyiam commented 4 years ago

@chaos08

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

stale[bot] commented 4 years ago

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[bot] commented 4 years ago

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.

qixiaobo commented 1 year ago

The same problem meet with sofa-ark