this piece of code has been working perfectly, i just refactored packages names and the spring context can no more inject this bean. I am sure btw that the new packages names still matches the @ComponentScan scope
@Repository("tenantsConfigRepository")
public interface TenantsConfigRepository extends JpaRepository<TenantsConfig, Long> {
public TenantsConfig deleteByName(String name);
}
@Service
public class TenantsConfigService {
TenantsConfigRepository tenantsConfigRepository;
@Autowired
public TenantsConfigService(TenantsConfigRepository tenantsConfigRepository) {
this.tenantsConfigRepository = tenantsConfigRepository;
}
public List<TenantsConfig> findAll() {
return tenantsConfigRepository.findAll();
}
public Optional<TenantsConfig> find(long id) {
return tenantsConfigRepository.findById(id);
}
public void saveOrUpdate(TenantsConfig tenantsConfig) {
tenantsConfigRepository.save(tenantsConfig);
}
public void delete(TenantsConfig tenantsConfig) {
tenantsConfigRepository.delete(tenantsConfig);
}
public void deleteByName(String name) {
tenantsConfigRepository.deleteByName(name);
}
}
Application failed to start and printing this text
***************************
APPLICATION FAILED TO START
**************************
Description:
Parameter 0 of constructor in com.example.admin.service.TenantsConfigService required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
thanks guys for responding, I figured it out, i was using a datasource from a configuration class, those configurations were scoped to be used to specific packages, i just changed thebasePackages
attribute to match the new packages names.
@Configuration
@EnableJpaRepositories(basePackages = "com.example.admin", entityManagerFactoryRef = "adminEntityManager", transactionManagerRef = "adminTransactionManager")
and
em.setPackagesToScan("com.example.admin.entity");
em refers to EntityManager
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments