As well as I know, it is not possible to use @Autowired
annotation for static
fields using Spring
. When I run my JBoss
server, everything works well but I can see few warnings:
Autowired annotation is not supported on static fields: private static ...
I do not use this annotation really often (in this project I have not used it yet) but maybe some of my colleagues found it more useful.
So, I took one of this warnings:
Autowired annotation is not supported on static fields: private static java.lang.String com.my.package.MyClass.myVariable
I opened this class and inside is:
@Value("${params.myvariable}")
private static String myVariable;
// getter
// setter
I opened config.xml
:
<bean id="myid" class="com.my.package.MyClass">
<property name="myVariable" value="${params.myvariable}" />
</bean>
As a last thing, I searched in Eclipse
of Autowired
strings in my project. Size of the result set was 0.
So my question is, what is a reason of warning:
Autowired annotation is not supported on static fields
in this case?
Thank you in advance