Issue
IN my springbootapp I have the following repository:-
@Repository
public class RevisionRepository {
private AuditReader auditReader;
public RevisionRepository(AuditReader auditReader) {
this.auditReader = auditReader;
}
}
When I run this app. I got this error:-
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-12-24 21:09:15 -
APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in com.howtodoinjava.demo.repository.RevisionRepository required a bean of type 'org.hibernate.envers.AuditReader' that could not be found.
Action:
Consider defining a bean of type 'org.hibernate.envers.AuditReader' in your configuration.
How can I make this work?
Solution
This fixed my issue. Hopefully, it will be helpful for others:-
@Configuration
public class RevisionConfiguration {
@Autowired
private AuditReader auditReader;
private final EntityManagerFactory entityManagerFactory;
public RevisionConfiguration(EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}
@Bean
AuditReader auditReader() {
return AuditReaderFactory.get(entityManagerFactory.createEntityManager());
}
}
Answered By - masiboo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.