i'm using spring boot 2.2.5.RELEASE and spring-data-2.2.5.RELEASE
we have multiple projects in different git repositories and I'm trying to create a common JSON repository to work with MySQL JSON functions via shared jar.
i created the following in my common jar which has an autoconfiguration
@NoRepositoryBean
public interface JsonRepository <T>{
int appendToArray(T entity, String arrayPath, Object item, String storeId) throws JsonProcessingException;
int removeFromArrayByValue(T entity, String arrayPath, String feild, String value, String storeId);
}
configuration class
@EnableJpaRepositories(repositoryBaseClass = JsonRepositoryImpl.class,
repositoryFactoryBeanClass = JsonRepositoryFactoryBean.class
)
@Configuration
public class RepositoryConfig {
}
and i have a spring.factorie
files in my resources which configures this as autoconfiguration
and my implementation repository
@Repository
public interface SettingsRepository extends JsonRepository<Settings>, CrudRepository<Settings, Long> {
}
the problem
when i consume my common jar which include all json commons i made, spring-data stopes detecting all repositories and i can't start the application because of missing beans
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXService' defined in file [XXXService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxx.XXXRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
it only works if i add another @configuration in the consuming project, and i want to make it work automatically to save defining it on every project i want to add JSON query capabilities
@EnableJpaRepositories(
repositoryBaseClass = JsonRepositoryImpl.class,
repositoryFactoryBeanClass = JsonRepositoryFactoryBean.class,
basePackages = "xxx.*"
)
public class CoreConfig {
}
how i can fix it ??