spring-data-dynamodb icon indicating copy to clipboard operation
spring-data-dynamodb copied to clipboard

Multiple DynamoDBMapperConfig beans and dynamoDBMapperConfigRef wiring issue

Open gerrytan opened this issue 6 years ago • 5 comments

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

  1. Setup 2 or more repositories, each with its own dynamoDBMapperConfigRef
  2. 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.

gerrytan avatar Jul 10 '19 14:07 gerrytan

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?

zorrofox avatar Sep 25 '19 08:09 zorrofox

same issue

xmeng1 avatar Oct 12 '19 21:10 xmeng1

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?

thanders avatar Nov 21 '19 14:11 thanders

me too, I have to rollback again... hope someone can fix this issue.

YYSAM avatar Apr 04 '20 04:04 YYSAM

what's the resolution here?

RaghuJ avatar Jan 28 '21 08:01 RaghuJ