-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with spring-data-rest #15
Comments
Great project. Vote +1 for this feature. |
I managed a way of doing it. It is already deployed in a project I am working currently. I will put it in a pull request. |
Hi @fjvieira , have you had a chance to submit the pull request? I'm also facing this problem with version 4.4.1. |
Hey, @gvasselai , sorry to be late. I provided an example project with it. You can check it on https://github.com/affinitas/DynamoDBExample Regards. |
Thanks @fjvieira you rock , that solved the issue with resolutions for post requests ,specially via the HAL browser . |
The issue is because Spring Data Rest uses PersistentEntityResourceAssembler when rendering the resource. PersistentEntityResourceAssembler should use the DynamoDBMappingContext, however as this hasn't been constructed as a Spring Bean, it isn't picked up. Simply declaring a DynamoDBMappingContext Spring Bean doesn't work either as it needs to be initialised. @fjvieira example project initialises DynamoDBMappingContext, however it means 2 separate instances of DynamoDBMappingContext are created. If we expose the ability to inject a DynamoDBMappingContext bean into DynamoDBRepositoryConfigExtension we can avoid the initialisation code in the Application Configuration. Also, it'll mean a single instance of DynamoDBMappingContext will be used. I've created a PR to allow the DynamoDBMappingContext to be declared as a Spring Bean and initialised correctly. If the PR is accepted, the Application Configuration for a Spring Data Rest service would be as follows: @Configuration
@EnableDynamoDBRepositories(basePackages = "com.acme.repositories", mappingContextRef = "dynamoDBMappingContext")
public class DynamoDBConfig {
@Value("${amazon.dynamodb.endpoint}")
private String amazonDynamoDBEndpoint;
@Value("${amazon.aws.accesskey}")
private String amazonAWSAccessKey;
@Value("${amazon.aws.secretkey}")
private String amazonAWSSecretKey;
@Bean
public AmazonDynamoDB amazonDynamoDB(AWSCredentials amazonAWSCredentials) {
AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials);
if (StringUtils.isNotEmpty(amazonDynamoDBEndpoint)) {
amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint);
}
return amazonDynamoDB;
}
@Bean
public AWSCredentials amazonAWSCredentials() {
// Or use an AWSCredentialsProvider/AWSCredentialsProviderChain
return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
}
@Bean
public DynamoDBMappingContext dynamoDBMappingContext() {
return new DynamoDBMappingContext();
}
} |
Thanks to @boothen and his PR #168 this was merged into |
The text was updated successfully, but these errors were encountered: