Пытается подключиться к aws DynamoDB, но в настоящее время работает с ошибкой, показанной в заголовке.Что я делаю не так?
Я посмотрел другие онлайн-решения, на которые не нашел ответа, который работал бы для меня.
Полная ошибка -
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController': Unsatisfied dependency expressed through field 'Service_functions'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountHelper': Unsatisfied dependency expressed through field 'dynamoDBRepo'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamoDBRepo': Cannot create inner bean '(inner bean)#4ed4a7e4' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4ed4a7e4': Cannot resolve reference to bean
'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'entityManagerFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Класс модели -
@DynamoDBTable(tableName = "Users")
public class User {
@DynamoDBAutoGeneratedKey
@DynamoDBHashKey(attributeName = "_id")
private String _id;
private String bloodGroup;
private String firstName; // DO NOT change this, needs to stay firstName
private String surname;
private String email;
private String password;
private String addressline;
private String postcode;
private String latitude;
private String longitude;
public User() {}
// More Constructors, Getters & Setters
Класс учетной записи -
@Service
public class AccountHelper {
@Autowired
private DynamoDBRepo dynamoDBRepo; // Im guessing the repo is failing to autowire?
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
public User create(String bloodGroup, String firstname, String surname, String email, String password, String addressline, String postcode) {
return dynamoDBRepo.save(new User(bloodGroup, firstname, surname, email, bCryptPasswordEncoder.encode(password), addressline, postcode));
}
}
Хранилище
@Repository
@EnableScan
public interface DynamoDBRepo extends CrudRepository<User, String> {
User findByFirstName(String firstName);
User findByEmail(String email);
}
Контроллер -
@Controller
@Component
public class AccountController {
@Autowired
private AccountHelper Service_functions;
@ResponseBody
@PostMapping(value = "/create/{bloodGroup}/{firstname}/{surname}/{email}/{password}/{addressline}/{postcode}")
public String create( @PathVariable String bloodGroup , @PathVariable String firstname, @PathVariable String surname, @PathVariable String email, @PathVariable String password, @PathVariable String addressline, @PathVariable String postcode){
User CreateUser = Service_functions.create(bloodGroup, firstname, surname, email, password, addressline, postcode);
System.out.println("this is working");
return CreateUser.toString();
}
}
Начальная точка -
//@EnableEurekaClient
@SpringBootApplication
@EnableJpaRepositories("com.bdonor.accountservice.Repository")
public class AccountServiceApplication {
public static void main(String[] args) {
SpringApplication.run(AccountServiceApplication.class, args);
}
}
Зависимости -
<dependencies>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-mongodb</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.github.derjust</groupId>
<artifactId>spring-data-dynamodb</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--https://mvnrepository.com/artifact/com.google.code.gson/gson-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.17</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.10</version>
</dependency>
</dependencies>
Буду признателен за любую помощь / предложения по этому вопросу!