I'm creating a custom starter for spring boot.
I've this class for configuration of autostarter
@Configuration
@AutoConfigureAfter(SpringDataWebAutoConfiguration.class)
@ComponentScan(basePackages = {"com.closure.table"})
public class ClosureTableAutoConfiguration {
CategoryTypeRepository categoryTypeRepository; // is under com.closure.table.repository and is annotated
public ClosureTableAutoConfiguration(CategoryTypeRepository categoryTypeRepository){
this.categoryTypeRepository = categoryTypeRepository;
}
@Bean
@ConditionalOnMissingBean
public ClosureTable closureTable() {
return new ClosureTable();
}
@Bean
@ConditionalOnMissingBean
@DependsOn("CategoryTypeRepository")
public CategoryTypeService getCategoryTypeService() {
return new CategoryTypeService(categoryTypeRepository);
}
...
The starter applications works perfectly, inside a classic web application, if I don't use repository inside service, otherwise I got this error:
Consider defining a bean of type 'com.closure.table.repository.CategoryTypeRepository' in your configuration.
In web application I've create a configuration class like this
@Configuration
@Import({ClosureTableAutoConfiguration.class})
public class ClosureTableConfiguration {
}
Is there a way to accomplisce this scope?