Additional datastore registration (for testing)


I have an additional datastore created, and works Ok on the UI.

But when I want to implement some testing on the store Jmix complains “Store XXXX is not registered”.

How does one register the additonal datastore on the XXXTestConfiguration class? note that I need it to pull the properties from the file (as the StoreConfiguration class does)

I have been looking at the source code trying to understand this, so far I found things like this:

    DataSource db1DataSource() {
        return new EmbeddedDatabaseBuilder()

Which works for registering data sources with the EmbeddedDatabase.

That gave me the idea of doing something like…:

    DataSource db1DataSource(MyStoreConfiguration myStoreConfiguration) {
        // instantiate the dataSource

But it fails miserably complaining that no beans can provide MyStoreConfiguration (which is on MyStoreConfiguration.class next to the main Configuration class.

I see I could instantiate the DataSource by hand like here but I need the Configuration class to read the properties file (I want to put in some integration tests that make sure the MSSQL database works as expected)

So… still stuck not knowing how to register my additional dataSource for testing :frowning:

Why do you need another configuration class?
What about creating src/test/resources/ file and using test profile when running tests like this:

public class MyTest {


By the MyStoreConfiguration.class class I was referring to the class that Studio creates in the main package to load the datastore configuration. Not an additional class. Full class bellow (collapsed)

public class MyStoreConfiguration {

    DataSourceProperties myDataSourceProperties() {
        return new DataSourceProperties();

    @ConfigurationProperties(prefix = "my.datasource.hikari")
    DataSource myDataSource(@Qualifier("myDataSourceProperties") DataSourceProperties properties) {
        return properties.initializeDataSourceBuilder().build();

    LocalContainerEntityManagerFactoryBean myEntityManagerFactory(
            @Qualifier("myDataSource") DataSource dataSource,
            JpaVendorAdapter jpaVendorAdapter,
            DbmsSpecifics dbmsSpecifics,
            JmixModules jmixModules,
            Resources resources) {
        return new JmixEntityManagerFactoryBean("my", dataSource, jpaVendorAdapter, dbmsSpecifics, jmixModules, resources);

    JpaTransactionManager myTransactionManager(@Qualifier("myEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
        return new JmixTransactionManager("my", entityManagerFactory);

By doing that the application context loads without complaining about the dataStore not being registered. But then when I try to use it I get: No bean named ‘myStoreTransactionManager’ available

It is as if the aforementioned configuration class (which provides the dataStore beans) is never loaded. But when running the application it is there.

I should also mention that this is an addon module, not application module.


It suddently started working.
I’ll try to find out why/how :woman_shrugging:

Did you find out what was the reason?

I have been unable to reproduce. Probably some caching issue