title: How can I ensure that one spring-boot-starter is loaded before another?
body: <p>I'm trying to ensure that one Spring Boot Starter is loaded before another. In this case, I have a custom spring boot starter written by my organization and the spring-boot-starter-data-jpa starter. It's crucial that the custom starter's bean is ran before spring-boot-starter-data-jpa is initialized. An example snippet of the dependencies in pom.xml:</p>
  <pre class="lang-xml prettyprint-override"><code>    &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.example&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-my-customer-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  <p>How would one go about this? The solution I'm currently considering is adding a <code>@Primary</code> annotation to the top of the bean initialized in my company's custom starter, not sure if this would work and looking for best practice here. The bean I'm attempting to load in the custom starter before spring-boot-starter-jpa's beans are loaded is responsible for setting proxy settings, therefore must be loaded first so that traffic to the database can be routed via proxy.</p>