title: Setting a variable through Spring in a dependency?
body: <p>I have two separate classes, each class is in a different jar. Class B is a dependency of A. I want to be able to pass a value in a variable in Class A (a url loaded from a config file) into B. However, I am having trouble doing so as the value is always being populated as null.</p>
  
  <pre><code>public class A {
  
  @Value("${url.name}")
  private String url;
  
  ...
  
  B b = new B();
  </code></pre>
  
  <p>Here is my class B</p>
  
  <pre><code>@Component
  public class B implements BInterface {
  
  @Autowired
  private String url
  </code></pre>
  
  <p>I have debugged and confirmed that the URL loads successfully in class A, but however doesn't seem to get passed into B. Can anyone suggest where I am going wrong? Please note that class B is in a completely separate JAR from A, and I think that is where the heart of the problem lies. Essentially, I would like to know the best way that I can pass a value that is in a JAR in class A, and then pass that value to a class in class B whose JAR is a dependency or A.</p>