user1999099
user1999099

Reputation: 161

Spring property value is null in a specific bean

Not able to read property value in a bean that is present in jar file but able to read the same property value in bean that is present in classes folder

I have a class PSContext.java which is packaged in X.jar. I have a bean tht is present in classes folder CFContent.java. I am able to read the property value in this file.

@Value("${ps.test}")
private String test;

But the same value I am not able to read it in PSContext.java. This bean is transient. But it should not matter I think. Can someone let me know what is going wrong.

Regards, JN

Upvotes: 1

Views: 590

Answers (2)

user1999099
user1999099

Reputation: 161

In my case, the bean where I was trying to get these values in not autowired. In beans where we have proper autowiring I was able to read these values

Upvotes: 0

Grim
Grim

Reputation: 1974

Try

 @DependsOn("ps")
 public class ..... {
   @Value("${ps.test}")
   private String test;
   ....
 }

Upvotes: 2

Related Questions