We do not recommend connecting to multiple external databases, but we understand that your limits
data may not exist in the same location.
It is technically possible to connect Atoti Limits to multiple external databases.
This is not a feature we intend to support out-of-the-box, however if you would like to do so, the general steps
are:
Create a new datasource configuration in your application.yml similar to
the limits.application.datasource configuration
Map the repositories to the datatables you would like to use with this datasource. You will need
to add a Spring @Configuration class
similar to LimitsJpaConfig.java. The important parts are:
Enabling the JPA Repositories: the repositories specified by basePackageClasses will be mapped
to YOUR_TRANSACTION_MANAGER_FACTORY.
The example below will only map the ILimitStructuresJpaRepository repository to its equivalent
datatable in the datasource.
Exposing your transaction manager: you need to expose your transaction manager as a Spring bean.
@Beanpublic LocalContainerEntityManagerFactoryBean yourEntityManagerFactory(){ LocalContainerEntityManagerFactoryBean em =new LocalContainerEntityManagerFactoryBean();// configure me with your datasource...
return em;}@Beanpublic PlatformTransactionManager yourTransactionManager(){returnnew JpaTransactionManager(entityManagerFactory);}
Configure your custom persistence service to use
the correct transaction manager.
For an example of how this is done see the @Transactional annotation in
the DefaultLimitsAppCrudService class.