Spring MVC @PropertySource all Key/value as a map


In my Spring MVC application, I want to read <strong>ALL key/values</strong> from a specify properties file. I am including the properties file to my java class by


and can read a one key at a time

@Autowired Environment env;

and env.getProperty("userIdEmail")

Please help me how to get all key/value as a <strong>map</strong>

Thanks Manu


One way to achieve the same is <a href="https://stackoverflow.com/questions/23506471/spring-access-all-environment-properties-as-a-map-or-properties-object" rel="nofollow">Spring: access all Environment properties as a Map or Properties object</a> and secondly is:

<bean id="myProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:user-form-validation-configuration.properties"/> </bean>

For, Annotation based:

@Bean(name = "myProperties") public static PropertiesFactoryBean mapper() { PropertiesFactoryBean bean = new PropertiesFactoryBean(); bean.setLocation(new ClassPathResource( "user-form-validation-configuration.properties")); return bean; }

Then you can pick them up in your application with:

@Resource(name = "myProperties") private Map<String, String> myProperties;


  • Setting a path when creating a new File in Java
  • How to compare same PropertyInfo with different ReflectedType values?
  • Getting the new line character without System.getProperty(“line.separator”)?
  • Property file in java
  • How can I selectively modify the src attributes of script tags in an HTML document using Perl?
  • Rails 4.1 environment variables not reloading
  • How to create a custom Powershell operator?
  • My first C# WPF ValidationRule is not firing
  • jquery validation - waiting for remote check to complete
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • How to get current document uri in XSLT?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Login not working in Firefox in Meteor
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Spring Cloud Microservice Architecture Confusion
  • How to use JavaScript to determine whether a file exists in a directory?
  • How do I access an unhandled exception in an MVC Error view?
  • Transactional Create with Validation in ServiceStack Redis Client
  • Replace value with Factor in r data.table
  • How can I send an e-mail from a vbs script
  • How to get a value (ex: baseURL) in every Karate feature?
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Javascript Callbacks with Object constructor
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Weird JavaScript statement, what does it mean?
  • jQuery tmpl and DataLink beta
  • Apache 2.4 - remove | delete | uninstall
  • Is there a mandatory requirement to switch app.yaml?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • How to set the response of a form post action to a iframe source?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • UserPrincipal.Current returns apppool on IIS