Open
Description
In updating to 5.1.0, on startup we're now getting:
Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dynamoDBMapper' defined in class path resource [{Propriety class details removed}]: Unsatisfied dependency expressed through method 'dynamoDBMapper' parameter 1; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig' available: expected single matching bean but found 2: dynamoDBMapperConfig,dynamoDB-DynamoDBMapperConfig
We're creating the DynamoDBMapperConfig as per https://github.com/derjust/spring-data-dynamodb/wiki/Alter-table-name-during-runtime.
Looks like something else is also now creating a DynamoDBMapperConfig.
Should these be created now in a different fashion?
Activity
tiagocpeixoto commentedon Feb 7, 2019
@GynnRickerbyNZPost
I had the same problem and I found out that I was configuring another DynamoDBMapperConfig bean.
So I removed this extra bean and the error stopped, remaining only the
dynamoDB-DynamoDBMapperConfig
.Best regards,
Tiago Peixoto.
GynnRickerbyNZPost commentedon Feb 7, 2019
Yes, but I need to configure the DynamoDBMapperConfig to specify table name overrides.
The
dynamoDB-DynamoDBMapperConfig
one is being created internally (and seems didn't use to be in previous versions), and there's no obvious new documentation on how to turn it off.tiagocpeixoto commentedon Feb 10, 2019
@GynnRickerbyNZPost
Have you tried to set
dynamoDBMapperConfigRef
property of@EnableDynamoDBRepositories
to point to your custom config?For exemple (in Kotlin):
GynnRickerbyNZPost commentedon Feb 10, 2019
Yes. And works fine in 5.0.4.
GynnRickerbyNZPost commentedon Feb 10, 2019
A quick looking around the code, it looks like DynamoDBMapperConfigFactory was added in 5.1.0, as a FactoryBean which Spring Boot is picking up.
Unfortunately since I've got it working with 5.0.4 I don't have the spare time (project manager is happy with older version working) to go back and work out the appropriate config to override the FactoryBean to use my own settings.
emckissick commentedon Feb 12, 2019
I ran into this same problem in Spring Boot, but didn't have to override the factory bean, I just removed the ConfigRef from the @EnabledDynamoDBRepositories annotation. If you have a DynamoDBMapperConfig bean the postProcessAfterInitialization method in the DynamoDBMapperConfigFactory will find it and use it.
Have you tried changing
@EnableDynamoDBRepositories(dynamoDBMapperConfigRef = "dynamoDBMapperConfig")
to just this
@EnableDynamoDBRepositories
If this is the correct intent, the documentation found here Alter table name during runtime may need to be updated.
fix: issue derjust#233 (checks if dynamoDBMapperConfigRef is set befo…
tiagocpeixoto commentedon Feb 24, 2019
I created a PR. Hope it helps!
Feel free to give me feedback.
refactor: add issue derjust#233 fix test
fix: issues derjust#230 and derjust#233
fix: issues derjust#230 and derjust#233
tiagocpeixoto commentedon Mar 9, 2019
I made a new fix related to this issue.
9 remaining items