title: Spring Boot app "bean name for bean class conflicts with existing" - how to exclude package/Class from 3rd party library/dependency?
body: <p>I have a Spring Boot application that I recently migrated from 1.x.x to 2.x.x. I am using a few 3rd party libraries/JARs to do some logging of metrics using Prometheus.</p>
  <p>The problem is I have (2) Java Classes named <code>PrometheusServletAutoConfiguration</code> that are both annotated with <code>@Configuration</code> and I'm getting the infamous Spring exception:</p>
  <pre><code>org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'prometheusServletAutoConfiguration' for bean class [com.my.package.path1.PrometheusServletAutoConfiguration] conflicts with existing, non-compatible bean definition of same name and class [com.my.package.path2.PrometheusServletAutoConfiguration]
  </code></pre>
  <p>So as you see, they do have slightly different FQDN (full qualified domain names, or package paths AND I simplified it for this example as you can see) but the main class is the same name so I think Spring is trying to figure out which Bean to create and failing. This utterly perplexes me, and I looked at the code/libraries in IntelliJ with Spring 1.x.x off the old branch code, and <strong>this exception was never thrown</strong> (was it ignored in Spring 1.x.x or something?). I also will note the code compiles fine, but fails at Runtime (makes sense)</p>
  <p>Was is the best resolution here? Should I just tell Spring to NOT scan one of these classes FQDN, such that it only creates 1 bean in the Application Context? Remember, these are 3rd party libs that  <em><strong>I cannot edit</strong></em>.</p>
  <p>I am using the <code>@SpringBootApplication</code> on my Java class containing main method.</p>