问题描述:

I am using Spring Framework 4. I have common project like TestApplication which is Aspect based and pull logs on applications App1 and App2.

I am using @Configuration completely annotation based configuration in TestApplication.

App1 and App2 have separate spring Configuration and hence separate contexts and loads TestApplication individually.

Question:

while App1 is loaded, TestApplication's @Configuration gets loaded and within that file i need to get application name as App1.

Similarly when App2 is loaded, within @Configuration file of TestApplication I need to get application name as App2.

I tried using ApplicationContext's getApplicationName() method and works well locally. But in DEV/PROD regions might be using DNS and hence not applicable.

Suggestions please.

edited:

One approach identified is to update web.xml of application with context-param and value and access it via @Value(value="${context-param-name}") annotation. Works fine but requires property place holder to be configured in spring xml.

相关阅读:
Top