In the spring is a very easy feature class, which is a standard. The property file takes it and it's your bean.xm config.
Does anyone know that a class that does the same thing, and integrates with the spring in the same way, but accepts XML files for config In particular, I'm thinking of Apache digester-style config files. It would be quite easy to do this, I am thinking if someone is already there.
Suggestions?
I have just tested it, and it should work only.
The propertyholder configurator has a set properties percissure method, so you can use your own sub-class. The default property manager already supports the properties in XML format.
Just to show you the code that works for you:
JUnit 4.4 Test case:
Package organization .nkl; Import static org.junit.assert.assertEquals; Import static org.junit.assert.assertNotNull; Import org.junit.Test; Import org.junit.runner.RunWith; Import organization Source: Import organization Source: Import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @Contax Configuration (Places = {"Classpath: /org/nkl/test-config.xml"}) @Arnivith (SpringJunit Class 4 Classer) Public Class Property Content {@ etowar private bean bean; @Test Public Zero Test Property Placeholder Configurator () {Assignot Tot (Bean); AssertEquals ("fred", bean.getName ()); }}
Spring Config file test-config.xml
& Lt; / Bean & gt; & Lt; / Bean & gt;
XML property file properties.xml
- For details on usage, see.
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt ;! DOCTYPE Points SYSTEM "http://java.sun.com/dtd/properties.dtd"> & Lt; Properties & gt; & Lt; Entry key = "org.nkl.name" & gt; Fred & lt; / Entry & gt; & Lt; / Properties & gt;
And finally Bean:
package org.nkl; Public square bean {the name of the private string; Public string getName () {return name; } Public Zero Setname (string name) {this.name = name; }}
Hope this helps ...
Comments
Post a Comment