Announcement Announcement Module
Collapse
No announcement yet.
Check two util:properties for null and get a property from a non null one Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check two util:properties for null and get a property from a non null one

    Hi Everyone,

    Our application configuration differs from production and development, we put *.properties in classpathe in dev machines and the same files in confDir in our prod machines,

    dataContext file
    Code:
    <context:property-placeholder location="${confDir:}/jdbc.properties, ${confDir:}/webservice.properties" order="1" ignore-resource-not-found="true" ignore-unresolvable="true"/>
    <context:property-placeholder location="classpath:jdbc.properties, classpath:webservice.properties" order="2"/>
    I want to access properties with value in my classes using @Value, so I added the following line
    Code:
    <util:properties id="props" location="classpath:jdbc.properties" local-override="false" />
    I added the following code in class to check the property for null and autowire it
    Code:
    @Autowired
    @Value("#{props.getProperty('myProp') ?: 7}")
    private int myProp;
    the problem is I need to add util property tag like the following and also check whether the properties file exists in confDir
    Code:
    <util:properties id="props1" location="${confDir:}/jdbc.properties" local-override="false" />
    I should check bothe props and props1 for myProp and auto wire it to my class.

    Can someone please whether I can achieve this or not?
Working...
X