创建名称为“ customerRepository”的bean时出错:初始化方法的调用失败

时间:2019-01-22 08:35:14

标签: spring spring-boot spring-data-jpa spring-data amazon-dynamodb

我正在尝试使用this 文章将Spring Boot应用程序与DynamoDB连接。 但是我收到了这个错误,:

  

org.springframework.beans.factory.BeanCreationException:创建名称为'customerRepository'的bean时出错:调用init方法失败;嵌套异常是java.lang.AbstractMethodError:org.springframework.data.mapping.context.AbstractMappingContext.createPersistentProperty(Lorg / springframework / data / mapping / model / Property; Lorg / springframework / data / mapping / model / MutablePersistentEntity; Lorg / springframework / data / mapping / model / SimpleTypeHolder;)Lorg / springframework / data / mapping / PersistentProperty;

我的代码:

客户模型:

@DynamoDBTable(tableName = "Customer")
public class Customer {

private String id;
private String firstName;
private String lastName;

public Customer() {
}

public Customer(String id, String firstName, String lastName) {
    this.id = id;
    this.firstName = firstName;
    this.lastName = lastName;
}

@DynamoDBHashKey(attributeName = "Id")
public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

@DynamoDBAttribute(attributeName = "FirstName")
public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

@DynamoDBAttribute(attributeName = "LastName")
public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

@Override
public String toString() {
    return String.format("Customer[id=%s, firstName='%s', lastName='%s']", id, firstName, lastName);
}
}

DynamoDBConfig:

@Configuration
@EnableDynamoDBRepositories(basePackages = "com.DynamoTest.DynamoTest.repo")
public class DynamoDBConfig {

@Value("${amazon.dynamodb.endpoint}")
private String dBEndpoint;

@Value("${amazon.aws.accesskey}")
private String accessKey;

@Value("${amazon.aws.secretkey}")
private String secretKey;

@Bean
public AmazonDynamoDB amazonDynamoDB() {
    AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials());

    if (!StringUtils.isNullOrEmpty(dBEndpoint)) {
        dynamoDB.setEndpoint(dBEndpoint);
    }

    return dynamoDB;
}

@Bean
public AWSCredentials amazonAWSCredentials() {
    return new BasicAWSCredentials(accessKey, secretKey);
}
}

回购:

@EnableScan
@Repository
public interface CustomerRepository extends CrudRepository<Customer,String> 
{


}

0 个答案:

没有答案