Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

621
Visualizações
No qualifying bean of type 'javax.persistence.EntityManager' available: expected at least 1 bean which qualifies as autowire candidate

I have this problem...

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

I don't usually boot. these are configurations:

@Configuration
@EnableTransactionManagement
public class SpringOrmConfig {

    private final DataSource dataSource;

@Autowired
public SpringOrmConfig(@Qualifier("dataSource") DataSource dataSource) {
    this.dataSource = dataSource;
}

@Bean
public LocalContainerEntityManagerFactoryBean factoryBean(@Autowired Properties jpaProperties) {
    LocalContainerEntityManagerFactoryBean emFactoryBean = new LocalContainerEntityManagerFactoryBean();
    emFactoryBean.setDataSource(dataSource);
    emFactoryBean.setPersistenceUnitName("jpa-unit");
    emFactoryBean.setPersistenceUnitName("localContainerEntityManagerFactoryBean");
    emFactoryBean.setPersistenceUnitName("factoryBean");
    emFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    emFactoryBean.setPackagesToScan("my.package");
    emFactoryBean.setJpaProperties(jpaProperties);
    return emFactoryBean;
}
...

The problem occurs in this class

@Repository
public class MyRepoSpringOrmImpl extends AbstractSpringOrm<Group> implements MyRepo {

    @Autowired
    protected MyRepoSpringOrmImpl(EntityManager em) {
        super(em, My.class);
    }
...

configuration

@ComponentScan("my.package")
@PropertySource("classpath:db_config.properties")
@EnableWebMvc
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableTransactionManagement
public class ApplicationConfig implements WebMvcConfigurer {

    @Value("${driver}")
    String driver;
    @Value("${url}")
    String url;
    @Value("${login}")
    String login;
    @Value("${password}")
    String password;


    @Bean
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClass(driver);
        dataSource.setJdbcUrl(url);
        dataSource.setUser(login);
        dataSource.setPassword(password);
        return dataSource;
    }

I do not understand what's the matter... Help please

p.s. I deliberately didn't use Spring Boot because it's not allowed in my project

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda