Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:02:43+00:00 2026-05-11T04:02:43+00:00

Spring has a very handy convenience class called PropertyPlaceholderConfigurer , which takes a standard

  • 0

Spring has a very handy convenience class called PropertyPlaceholderConfigurer, which takes a standard .properties file and injects values from it into your bean.xml config.

Does anyone know of a class which does exactly the same thing, and integrates with Spring in the same way, but accepts XML files for the config. Specifically, I’m thinking of Apache digester-style config files. It would be easy enough to do this, I’m just wondering if anyone already has.

Suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:02:44+00:00Added an answer on May 11, 2026 at 4:02 am

    I just tested this, and it should just work.

    PropertiesPlaceholderConfigurer contains a setPropertiesPersister method, so you can use your own subclass of PropertiesPersister. The default PropertiesPersister already supports properties in XML format.

    Just to show you the fully working code:

    JUnit 4.4 test case:

    package org.nkl;  import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull;  import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;  @ContextConfiguration(locations = { 'classpath:/org/nkl/test-config.xml' }) @RunWith(SpringJUnit4ClassRunner.class) public class PropertyTest {      @Autowired     private Bean bean;      @Test     public void testPropertyPlaceholderConfigurer() {         assertNotNull(bean);         assertEquals('fred', bean.getName());     } } 

    The spring config file test-config.xml

    <?xml version='1.0' encoding='UTF-8'?> <beans xmlns='http://www.springframework.org/schema/beans'   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'   xmlns:context='http://www.springframework.org/schema/context'   xsi:schemaLocation=' http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd '>   <context:property-placeholder        location='classpath:/org/nkl/properties.xml' />   <bean id='bean' class='org.nkl.Bean'>     <property name='name' value='${org.nkl.name}' />   </bean> </beans> 

    The XML properties file properties.xml – see here for description of usage.

    <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'> <properties>   <entry key='org.nkl.name'>fred</entry> </properties> 

    And finally the bean:

    package org.nkl;  public class Bean {     private String name;     public String getName() { return name; }     public void setName(String name) { this.name = name; } } 

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Spring Batch process which has following kind of code. <step id=step1
I'm fairly new to Spring and I need a bean that has two properties
I have a Spring (3.1.) app that has a large app-context.xml file. There is
I have a Spring MVC application which has a public front-end WAR, an admin
I'm building very basic mvc application with Spring. It has one controller that should
Java String.replaceAll comes very handy. Has anyone encounter similar library in C++ (Even without
One of BoundField in my GridView has a very long string without space. I
I see that Spring has a @Required annotation to mark member variables in beans
I am working on a project that has Spring based Web Services and Spring
Does anybody has an experience with Spring Integration project as embedded ESB? I'm highly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.