@Profile annotation to use this configuration only for non test profile. This allows me to set a different datasource, e.g. H2, when running tests.

@EnableJpaRepositories is used for Spring Data. Note we are using the default transaction manager setup in Spring

Bean for primary datasource. The @ConfigurationProperties annotation specifies the prefix of the properties to use by this datasource. For the example here, the application.properties file should include properties like below:

Persistence unit name should be setup in the EntityManager bean as shown here.

Configure Secondary Entity Manager

Configuration of the secondary entity manager is very similar to that of the primary.The only thing is we have to define a new transaction manager. Make sure a different prefix is set in the configuration properties of the data source. Also, a different persistent unit name should be used.