Injecting static variables

Posted on 2014-01-22
Last Modified: 2014-01-24
Is it possible to inject static variables of one class into another using spring config ?
Question by:FranklinRaj22

Expert Comment

ID: 39802058
Can you please make it clear on what you meant by spring config.?

Accepted Solution

Mahesh Bhutkar earned 500 total points
ID: 39802138
You can use org.springframework.beans.factory.config.MethodInvokingFactoryBean.

Add setter method to inject the value.

Check this example :-

Expert Comment

ID: 39802253
question not clear

Author Comment

ID: 39806834
Sorry my mistake , I wanted to inject static variables from class A into Class B and wanted to do it via spring config file rather than doing it in the Class B code .

I used the below and it worked well .
util:constant static-field

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javap bin 2 40
servlet example issue 6 46
how to install java on RHEL image on EC2 4 39
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 56
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question