gpt4 book ai didi

java - org.springframework.beans.factory.BeanCreationException : in Ecommerce project

转载 作者:行者123 更新时间:2023-12-02 12:03:15 25 4
gpt4 key购买 nike

我使用 Spring boot 项目,当我运行时,出现以下错误,

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSecurityService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract Ecommerce.entities.User Ecommerce.repository.UserRepository.findByUsername(java.lang.String)!

我假设最后几行是错误堆栈中重要的内容,

Could not create query metamodel for method public abstract Ecommerce.entities.User Ecommerce.repository.UserRepository.findByUsername(java.lang.String)!

我有下面提供的用户存储库,

public interface UserRepository extends CrudRepository<User, Long> {

User findByUsername(String username);

User findByEmail(String email);
}

还提供了用户实体,

@Entity
public class User implements UserDetails {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "userId", nullable = false, updatable = false)
private Long userId;

private String userName;

private String password;

private String firstName;

private String lastName;

@Column(name = "email", nullable = false, updatable = false)
private String email;

private String phone;

private boolean enabled = true;

@OneToOne(cascade = CascadeType.ALL, mappedBy = "user")
private ShoppingCart shoppingCart;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<UserShipping> userShippingList;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<UserPayment> userPaymentList;

@OneToMany(mappedBy = "user")
private List<Order> orderList;

@JsonIgnore
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<UserRole> userRoles = new HashSet<>();


// ..............
// more lines of code for overriding the methods

}

这里有什么问题以及如何解决它?

最佳答案

在 Spring JPA 存储库中,自动生成的查找器遵循如下命名约定。

findBy<DataMember><Op> 

<Op>可以是“Like”、“Between”等。

关于java - org.springframework.beans.factory.BeanCreationException : in Ecommerce project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47088381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com