我正在与我的团队一起进行Spring项目,但遇到了这个错误。我在Google上进行了一些研究,但一无所获,所以我们继续。我把所有有关的文件放
Client.java
package com.takeandgo.beans;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
/**
* An entity Client composed by fields (id, email, name,password,tel,naissance).
* The Entity annotation indicates that this class is a JPA entity. The Table
* annotation specifies the name for the table in the db.
*
* @author Kambi Ben
*/
@Entity
@Table(name = "client_clt")
public class Client {
// ------------------------
// PRIVATE FIELDS
// ------------------------
// An autogenerated id (unique for each user in the db)
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "clt_id")
private int id;
// The user's name
@NotNull
@Column(name = "clt_prenom")
private String prenom;
// The user's email
@NotNull
@Column(name = "clt_login")
private String email;
// The user's password
@NotNull
@Column(name = "clt_mdp")
private String password;
// The user's phone
@NotNull
@Column(name = "clt_tel")
private String tel;
// The user's email
@NotNull
@Column(name = "clt_naissance")
private String naissance;
// ------------------------
// PUBLIC METHODS
// ------------------------
/**
*
*/
public Client() {
super();
// TODO Auto-generated constructor stub
}
public Client(int id, String prenom, String email, String password, String tel, String naissance) {
super();
this.id = id;
this.prenom = prenom;
this.email = email;
this.password = password;
this.tel = tel;
this.naissance = naissance;
}
public Client(String prenom, String email, String password, String tel, String naissance) {
super();
this.prenom = prenom;
this.email = email;
this.password = password;
this.tel = tel;
this.naissance = naissance;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getNaissance() {
return naissance;
}
public void setNaissance(String naissance) {
this.naissance = naissance;
}
}
IDaoClient.java 这是我的查询文件
package com.takeandgo.idao;
import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.takeandgo.beans.Client;
import com.takeandgo.beans.MailStatus;
@Transactional
public interface IDaoClient extends JpaRepository<Client, Integer> {
// return 0 or 1 if they okey needto describe this methode on ClientDAO
Client saveAndFlush(Client client);
Client findById(int id);
@Query("SELECT c FROM Client c WHERE c.email = :email AND c.password = :mdp")
public Client find(@Param("email") String email, @Param("mdp") String mdp);
MailStatus save(MailStatus mail);
//@Query("INSERT INTO MailStatus ms (ms.mail, ms.code, ms.status) VALUES(:mail, :code, :status)")
//public void addMail(@Param("mail") String mail, @Param("code") String code, @Param("status") String status);
@Query("UPDATE MailStatus ms SET ms.status = 'verified' WHERE ms.code = :code")
public String setVerified(@Param("code") String code);
@Query("SELECT COUNT(ms) FROM MailStatus ms WHERE ms.code = :code")
public void findCode(@Param("code") String code);
}
ClientDao.java
package com.takeandgo.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.takeandgo.beans.Client;
import com.takeandgo.beans.MailStatus;
import com.takeandgo.idao.IDaoClient;
// need the annotation Component for injection
@Component
public class ClientDao {
// injection
@Autowired
private IDaoClient iDaoClient;
public ClientDao() {
}
// return the client save in the DB
public Client addClient(Client client, String code) {
Client clientReturn = iDaoClient.saveAndFlush(client);
MailStatus ms = new MailStatus(client.getEmail(), code, "unverified");
iDaoClient.save(ms);
return clientReturn;
}
public Client findClient(Client client) {
Client clientFind = iDaoClient.find(client.getEmail(), client.getPassword());
return clientFind;
}
public void SetMailVerified(String code) {
iDaoClient.setVerified(code);
}
public boolean findCode(String code) {
try {
iDaoClient.findCode(code);
return true;
}catch(Exception e){
return false;
}
}
}
MailStatus.java
package com.takeandgo.beans;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
@Entity
@Table(name = "status_compte_sc")
public class MailStatus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "sc_clt_id_id")
private String id ;
@NotNull
@Column(name = "sc_clt_mail")
private String mail;
@NotNull
@Column(name = "sc_clt_code")
private String code;
@NotNull
@Column(name = "sc_clt_mail_status")
private String status;
public MailStatus(String mail, String code, String status) {
this.mail = mail;
this.code = code;
this.status = status;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
InscriptionController.java
package com.takeandgo.controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.takeandgo.beans.Client;
import com.takeandgo.dao.ClientDao;
import com.takeandgo.utils.RandomCodeGenerator;
import com.takeandgo.utils.SendMail;
@Controller
public class InscriptionController {
// ------------------------
// PUBLIC METHODS
// ------------------------
@Autowired
private ClientDao clientDao;
@RequestMapping(value = "/creat-client")
@ResponseBody
public void create(HttpServletRequest req, HttpServletResponse res, @ModelAttribute("user") Client client, Model model) throws IOException, JSONException {
System.out.println("-- in creat-client Action --");
String name = req.getParameter("name");
String email = req.getParameter("email");
String password = req.getParameter("password");
String tel = req.getParameter("tel");
String naissance = req.getParameter("naissance");
JSONObject json = new JSONObject();
// name.matches(regExpression);
String code = null;
RandomCodeGenerator rnd = new RandomCodeGenerator();
SendMail mail = new SendMail();
System.out.println(client.getPrenom()+ " - " + client.getEmail() + " - " + client.getPassword() + " - " + client.getPassword() + " - " + client.getNaissance());
if (name.length() != 0 && email.length() != 0 && password.length() != 0 && tel.length() != 0
&& naissance.length() != 0) {
json.put("SUCCESS", "OK");
json.put("REDIRECT", "/takeandgo/");
code = rnd.codeGeneratorForEmail();
mail.sendVerificationLink(name, email, code);
Client clientToSave = new Client(name, email, password, tel, naissance);
clientDao.addClient(clientToSave, code);
} else {
if (name != null) {
if (name.length() == 0) {
json.put("NAME", "KO");
}
if (name.length() > 0) {
json.put("NAME", "OK");
}
}
if (email != null) {
if (email.length() == 0) {
json.put("EMAIL", "KO");
}
if (email.length() > 0) {
json.put("EMAIL", "OK");
}
}
if (password != null) {
if (password.length() == 0) {
json.put("PASSWORD", "KO");
}
if (password.length() > 0) {
json.put("PASSWORD", "OK");
}
}
if (tel != null) {
if (tel.length() == 0) {
json.put("TEL", "KO");
}
if (tel.length() > 0) {
json.put("TEL", "OK");
}
}
if (naissance != null) {
if (naissance.length() == 0) {
json.put("NAISSANCE", "KO");
}
if (naissance.length() > 0) {
json.put("NAISSANCE", "OK");
}
}
}
returnJSON(res, json);
}
public void returnJSON(HttpServletResponse res, JSONObject json) throws IOException {
res.setContentType("application/json");
res.setCharacterEncoding("utf-8");
PrintWriter out = res.getWriter();
out.print(json.toString());
out.flush();
}
//
@RequestMapping(value = "/mail-verification/{code}")
@ResponseBody
public ModelAndView verifiedAccount(HttpServletRequest req, HttpServletResponse res, ModelMap model, @PathVariable String codeToVerify) {
ModelAndView mv = null;
if(clientDao.findCode(codeToVerify))
{
clientDao.SetMailVerified(codeToVerify);
System.out.println("Verification succes");
mv = new ModelAndView("public/Auth/MailVerificationOk");
}else {
System.out.println("Verification fail.... Something went wrong");
mv = new ModelAndView("public/Auth/MailVerificationFailed");
}
return mv;
}
}
ConnectionController.java
package com.takeandgo.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.takeandgo.beans.Client;
import com.takeandgo.dao.ClientDao;
/**
* Servlet implementation class ConnectionController
*
* @author Olamidé
*/
@Controller
public class ConnectionController {
@Autowired
private ClientDao clientDao;
@RequestMapping(value = "/connect-client", method = RequestMethod.POST)
@ResponseBody
public String connect(HttpServletRequest req, HttpServletResponse res, @ModelAttribute("user") Client client,
ModelMap model) {
String redirect = "";
Client clientToConnect = null;
try {
clientToConnect = new Client(client.getPrenom(), client.getEmail(), client.getPassword(), client.getTel(),
client.getNaissance());
clientDao.findClient(clientToConnect);
model.addAttribute("client", clientToConnect);
redirect = "redirect:index";
} catch (Exception e) {
redirect = "redirect:sigin";
}
return redirect;
}
}
运行代码时出现错误。首先,我在IDaoClient.java INSERT INTO ... VALUES中使用了@Query("INSERT INTO MailStatus ms (ms.mail, ms.code, ms.status) VALUES(:mail, :code, :status)")
来保存数据库,但是遇到了错误,因此我使用了JPA Repository方法save()并得到了这个信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.dao.ClientDao com.takeandgo.controller.ConnectionController.clientDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.idao.IDaoClient com.takeandgo.dao.ClientDao.iDaoClient; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IDaoClient': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at com.takeandgo.WebApplication.main(WebApplication.java:17) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.5.RELEASE.jar:1.3.5.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.dao.ClientDao com.takeandgo.controller.ConnectionController.clientDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.idao.IDaoClient com.takeandgo.dao.ClientDao.iDaoClient; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IDaoClient': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 22 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.idao.IDaoClient com.takeandgo.dao.ClientDao.iDaoClient; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IDaoClient': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.takeandgo.idao.IDaoClient com.takeandgo.dao.ClientDao.iDaoClient; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IDaoClient': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 35 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IDaoClient': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 37 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:235) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:373) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:353) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:84) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:62) ~[spring-data-jpa-1.9.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:100) ~[spring-data-jpa-1.9.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:211) ~[spring-data-jpa-1.9.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:74) ~[spring-data-jpa-1.9.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:416) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) ~[spring-data-commons-1.11.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) ~[spring-data-jpa-1.9.4.RELEASE.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 47 common frames omitted
就是这样...希望你们可以帮助我找到这个问题。
答案 0 :(得分:0)
您不能对两个实体MailStatus和Client使用相同的存储库。
您应该创建新的存储库MailStatusRepo extends JpaRepository<MailStatus, YOUR_ID>
,并在其中定义保存方法(但没有必要,因为Jpa默认提供这种方法)
我希望这能帮到您。祝你好运。