Multiple DynamoDBMapperConfig beans and dynamoDBMapperConfigRef wiring issue
We have a requirement to inject the table name at runtime, hence in version 4.5.0 we injected multiple DynamoDBMapperConfig, one per table, with a table name override.
For each table, we have a configuration bean with following annotation:
@Configuration
@EnableDynamoDBRepositories(
dynamoDBMapperConfigRef = "redacted*DynamoDBMapperConfig",
basePackageClasses = {*Redacted*Repository.class}
)
When upgrading to 5.1.0, application fail to start due to wiring issue
Expected Behavior
Application can start same as version 4.5.0
Actual Behavior
Application fail to start with following error
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of constructor in org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory required a single bean, but 4 were found:
- *redacted*DynamoDBMapperConfig: defined by method '*redacted*DynamoDBMapperConfig' in class path resource [*redacted*/*redacted*/*redacted*/*redacted*/dynamodb/*Redacted*DynamoDBConfig.class]
- dynamoDB-DynamoDBMapperConfig: defined in null
- *redacted*DynamoDBMapperConfig: defined by method '*redacted*DynamoDBMapperConfig' in class path resource [*redacted*/*redacted*/*redacted*/*redacted*/*redacted*/*redacted*/*Redacted*DynamoDBConfig.class]
- *redacted*DynamoDBMapperConfig: defined by method '*redacted*DynamoDBMapperConfig' in class path resource [*redacted*/*redacted*/*redacted*/*redacted*/*redacted*/*redacted*/*redacted*DynamoDBConfig.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Steps to Reproduce the Problem
- Setup 2 or more repositories, each with its own
dynamoDBMapperConfigRef - Start spring boot
Specifications
- Spring Data DynamoDB Version: 5.1.0
- Spring Data Version: 2.1.9.RELEASE
- AWS SDK Version: 1.11.583
- Java Version: 1.8.0_202
- Platform Details: macOS 10.14.5
All those information are logged by org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory on INFO level on startup.
Or use java -version and mvn dependency:tree | grep -E 'spring|aws' to provide those version numbers.
I have the same issue on 2.1.6.RELEASE Spring Data version, and I backward the Spring-Data-DynamoDB version to 5.0.4 to workaround. Anyone have work on 5.1.0 version on Spring Data version 2.1 above?
same issue
I have the same issue with :
<artifactId>spring-data-dynamodb</artifactId>
<version>5.1.0</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
I tried using previous versions of each and that doesn't seem to fix it. Does anyone know about a workaround?
me too, I have to rollback again... hope someone can fix this issue.
what's the resolution here?