I have a simple spring boot application in which I have a jpa repository object which i want to autowire inside an @Configuration
class like below.
@Configuration
public class Appconfig {
@Bean
@Autowired
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(OctopusPropertiesRepository repo) {
PropertySourcesPlaceholderConfigurer property = new PropertySourcesPlaceholderConfigurer();
Map<String,Object> props = new ConcurrentHashMap<>();
List<OctopusProperties> loadedSettings = repo.findAll();
loadedSettings.forEach(entry -> props.put(entry.getKey(), entry.getValue()));
MutablePropertySources mutablePropertySources = new MutablePropertySources();
mutablePropertySources.addFirst(new MapPropertySource("custom", props));
property.setPropertySources(mutablePropertySources);
return property;
}
}
And here is the @Repository
class
@Repository
public interface OctopusPropertiesRepository extends JpaRepository<OctopusProperties, Long> {
}
And I get following exception.
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.example.app.OctopusPropertiesRepository]
If i don't make that configuration and boot app successfully i see from the actuator that bean is available. What is the problem here? why I can't wire @Repository
inside @Configuration
.
P.S. These two java files are under same folder: com.example.app
P.P.S. Eclipse view of my project: