I have a class which is created with new B(this); in this class B I want to use a value from the application.properties. But because (as far as I understand) because it's not created with Spring it won't have any injection (I use the @Value annotation)
That is how the class is created:
@Component
public class A {
    public B getB(){return new B(this);}
    /**
        a lot more stuff
    **/
}
The class in question:
public class B {
    private A a;
    public B(A a){
        this.a = a;
    }
    @Value("${threshold}")
    private String threshold;  //this is null because it's not created with Spring
    public String getThreshold(){
        return threshold;
    }
    /**
        a lot more stuff
    **/
}
So my question is the following:
1) How can I use the value in the application.properties file or
2) How can I write B that it is created with Spring?
Some background information:
- I didn't wrote the initial code so I don't want to change too much but want to modify it so it can be maintained better in the future
- I don't have that much Spring knowledge and only start getting more and more familiar with it.
- In point 2) I'm struggling because of the constructorand how to set it via Spring...
Any help would be appreciated
 
     
     
     
     
    