尝试连接到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>
在此问题上的任何帮助/建议将不胜感激!