Skip to content

Can I autowire inject DynamodbTemplate? #275

Open

Description

@yjf27281181

I am trying to use the "Custom Repository implementations" feature. And I am following the code:
`
// Most important this class has to be named like the interface with an 'Impl' suffix
// https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behavior
public class DeviceValueRepositoryImpl implements DeviceValueAdditionRepository {

// Inject everything you want as this is created like a normal bean
@Autowired
DynamoDBTemplate dynamoDBTemplate;

@Override
public String fancyCustomMethod() {
    // custom code here

    DeviceValue dv = dynamoDBTemplate.load(DeviceValue.class, "42");
    if (dv == null) {
        return "Not found";
    } else {
        return dv.getTag();
    }
}

}
`

However, it seems the spring container does not contain dynamoDBTemplate. So how can I use dynamoDBTemplate in my own repository?

Specifications

  • Spring Data DynamoDB Version: 5.0.4
  • Spring Data Version: 2.0.9
  • AWS SDK Version:
  • Java Version: 1.8
  • Platform Details: windows10

Activity

  1. efenderbosch commented on Jan 17, 2020

    @efenderbosch

    We are doing this. Inject DynamoDBOperations instead as that's the interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions