Multi-data sources use JPA and EM, or report the default data source report failed to find the table, or the error does not have such an entity, DEBUG debugging is the first EM.I have been troubled by this problem for a long time, and the record is solved:
EntityManagerFactorySecondary refers to the second data source in the Springboot project, which indicates the entity manager that imports the second data source.
@PersistenceContext(unitName="entityManagerFactorySecondary") EntityManager em;
String sql = " SELECT COUNT(*) FROM msg_examine_producer"+day; Query query =em.createNativeQuery(sql); List outData = query.getResultList()
Remember to turn off the entity manager after running out