0

I want to add a new annotation based stereotype like @Service, into my starter project, but i don't know how to handle the registration process of that bean.

I found a solution loike

final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AnnotationTypeFilter(MyCustomAnnotation.class));
for (BeanDefinition entry : provider.findCandidateComponents("my.package.name")) {
  ...
    /* register the Bean into the Spring Context */
  ...
}

But I don't want a hard coded "package-path", cuz I don't know the Package the starter is used in.

Is there a solution for my problem?

Thx a lot!

PunkPengu
  • 32
  • 1
  • Are you trying to do something similar to [`@EnableFeignClients`](https://github.com/spring-cloud/spring-cloud-openfeign/blob/master/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java)? It has an attribute `basePackages` which a client can specify. Also are you aware of `ImportBeanDefinitionRegistrar`. You can take a look at [`FeignClientsRegistrar`](https://github.com/spring-cloud/spring-cloud-openfeign/blob/master/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java) as a reference. – Denis Zavedeev May 01 '20 at 14:33
  • I don't wan't the client to specify the basePackage. I wan't to register all Classes I annotaded with a specific Annotation (I defined in my Starter) in the Project which includes the Starter – PunkPengu May 03 '20 at 10:50

0 Answers0