Property Setting: URL : XML Bean Property « Spring « Java






Property Setting: URL

       
File: context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="testBean" class="PropertyEditorTestBean">
    <property name="myUrl" value="http://www.java2s.com"/>
  </bean>
</beans>


File: Main.java

import java.net.URL;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class Main {

  public static void main(String[] args) throws Exception {
    BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("context.xml"));
    PropertyEditorTestBean testBean = (PropertyEditorTestBean) beanFactory.getBean("testBean");

    System.out.println(testBean.getMyUrl());
  }
}

class PropertyEditorTestBean {
  private URL myUrl;

  public URL getMyUrl() {
    return myUrl;
  }

  public void setMyUrl(URL myUrl) {
    this.myUrl = myUrl;
  }
}




           
       








Spring-PropertySettingURL.zip( 2,598 k)

Related examples in the same category

1.PropertySetting: String Array
2.Property Setting: Stream From URL
3.Property Setting: Properties
4.Property Setting: Integer
5.Property Setting: File
6.Property Setting: Class type
7.Property Setting: Byte Array
8.Property Setting: Boolean
9.Property Setting: BigDecimal
10.Properties Setting: Date
11.Load property File In Context
12.lazy init
13.Fill Value To List
14.Fill Map
15.Fill Set
16.Fill Properties
17.Fill List To Another List
18.Fill Calendar Object To List
19.Create List Map In Context
20.Bean Injection: Map
21.Bean Injection Collection: Set
22.Bean Injection: Collection Properties
23.Bean Injection Collection: Map
24.Bean Injection Collection: List