Search code examples
micronautmicronaut-data

Associate JDBC Datasource Name Using @JdbcRepository annotation


In the docs, it states,

The @JdbcRepository annotation accepts an optional string value which represents the name of the connection or datasource in a multiple datasource scenario. By default Micronaut Data will look for the default datasource.

However, I don't see any such value parameter within this annotation - only the dialect. Is this an error or am I missing something?


Solution

  • Here is a complete snippet, using dialect & datasource:

    @Repository(value = "inventoryDataSource")
    @JdbcRepository(dialect = Dialect.ORACLE)
    public interface PhoneRepository extends CrudRepository<Phone, Integer> {
        Optional<Phone> findByAssetId(@NotNull Integer assetId);
    }
    

    A patch/pull request has been submitted with correction to the documentation.