• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Read properties file of one application from anther application in Spring

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


How to read properties file of one application from anther application in Spring 4.1.6 ?

Thank you in advance
 
Bartender
Posts: 1164
38
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch! Your question is a bit generic.Could you provide more details?
 
kanha senapati
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 2 project .Suppose the names are  "ProjectA", "ProjectB"
1.ProjectA is a library project.
2.ProjectB is main project.

ProjectB contains a properties File.

I want to access a properties file value of ProjectB in ProjectA.(means library Project want to read main project's property file)

FYI:Both The project deployed in same location.

Thanks
 
Claude Moore
Bartender
Posts: 1164
38
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, spring makes easy to read a project's application.properties file from within the project itself, what you are asking for could be done - I presume, but honestly I don't know how. I guess it would be tricky.
Anyway I wonder why , in a library (no matter if spring based on not) , you should need to read properties of the main project that is using your library. Shouldn't be the opposite, i.e let the main project override properties of libraries it's using?
 
kanha senapati
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"let the main project override properties of libraries it's using?" -->This is not possible.

Is it not possible if both the project running in same classpath?(library project can access main project's properties file)

 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a quick test with a small Spring Boot 2.1.6 application, and the application.properties files from my shared library was not recognised. Even properties that did not overlap were not reported in the env actuator.

I have a question. Why do you need to include an application.properties file in your shared library? Is it for configuration of your shared library itself, or is it to provide shared defaults? If it is the former, you can just define defaults where you use the properties: either as hard-coded values in your properties class, or with ${property:default} if you're injecting properties directly.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!