No qualifying bean of type [br.com.spring.JPA.Service.PostService] found for dependency

1

Can anyone help me with this error?

No qualifying bean of type [br.com.spring.JPA.Service.PostService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 
    {@org.springframework.beans.factory.annotation.Autowired(required=true)}

PostRepository:

@Repository
public interface PostRepository<P> extends JpaRepository<Post, Long> {
}

PostService:

@Service
public class PostService {

@Autowired
PostRepository<Post> postRepository;

@Transactional
public List<Post> getAllPosts() {
    return (List<Post>) postRepository.findAll();
} ...

JPAConfig:

@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages="br.com.spring")
@EnableJpaRepositories("br.com.spring.JPA.Repository") 
public class JPAConfig {
@Bean
public EntityManager entityManager(EntityManagerFactory entityManagerFactory) {
    return entityManagerFactory.createEntityManager();
}      

@Bean
public EntityManagerFactory createEntityManagerFactory() {
    return Persistence.createEntityManagerFactory("PU");
}

@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(emf);
    return transactionManager;
}
}

PostController:

@Controller
public class PostController {

@Autowired
PostService bd;
...
    
asked by anonymous 19.07.2018 / 02:21

0 answers