Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Can we use @Environment twice in the spring application with different classes?

 
Ranch Hand
Posts: 227
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I 'm trying to access the properties file other than a place where all the application's configuration resides, so I'm trying to use @Environment twice in my applicatiobn.  I'm trying to load a properties to implement a email notification functionality to access the properties file using @Environment by Autowiring.  But I'm failing while reading the property file using env.getProperty("email.smtp.host")); Getting null in the place of property value when executing the app.  Actually, I'm trying to use two Configuration file, is this what blocks me to autowire Environment property ? I tried to replace with @Component and adding email package to componentscan list as well.  Can you someone shed some light on this please ?

1. Tried to resolve this by implementing EnvironmentAware  interface as below to get the property value using load() but that still didn't help me.



 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!