Results 1 to 2 of 2

Thread: NullPointerException while Injection below sources, how to use a ref tag

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Default NullPointerException while Injection below sources, how to use a ref tag

    How to Injection when there are below Glo.java sources.

    this is my configuration.
    ---------------------------context.xml------------------------

    <bean id="glo" class="com.core.Glo">
    <property name = TYPE1 value="TEST.getproperty("test.type")"
    </bean>

    --> I want to fix the value of "TEST.getproperty("test.type")"

    ---------------------Glo.java-------------
    public class Glo {

    public static final String TYPE1 = TEST.getProperty("test.type");

    }
    --------------------TEST.java-----------
    public class TEST{

    public static String getProperty(String key){
    FileInputStream fis = null;
    Properties props = new Properties();
    fis = new FileInputStream("gol.properties");
    props.load(new java.io.BufferedInputStream(fis));
    return props.getProperty(keyName).trim();
    }
    }
    ---------------glo.properties-------------
    test.type = 1
    test.type2 = 2

  2. #2
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    287

    Default

    You want to read some properties from a property file?

    http://static.springsource.org/sprin...lderconfigurer
    Amila Domingo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •