Попытка создать базовый веб-сервис с помощью jpa / hibernate. Но бобы не инициализируются. Может ли кто-нибудь помочь мне в этом?
ниже - это мой CustomerController.java:
@RestController
public class CustomerController {
@Autowired
CustomerService service;
@SuppressWarnings("deprecation")
@PostMapping(value = "/getCust", consumes=MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<CustomerModel> retriveCustomers(@RequestBody CustomerModel cust){
System.out.println(cust); //just to see the object in console
List<CustomerModel> resp = service.getCustomers();
return resp;
}
}
ниже - это мой CustomerService.java:
@Service
public class CustomerService {
@Autowired
CustomerRepository repo;
public List<CustomerModel> getCustomers() {
List<CustomerModel> resp=repo.getAllCustomers();
return resp;
}
}
, ниже - мой CustomerRepository. java:
@Repository
public interface CustomerRepository extends CrudRepository<CustomerModel, Integer>{
List<CustomerModel> getAllCustomers();
}
ниже - мой CustomerModel.java:
@Entity
@Table(name="aliens")
public class CustomerModel {
@Id
@Column(name="customer_id")
private String customerId;
@Column(name="customer_name")
private String customerName;
@Column(name="customer_email")
private String customerEmail;
@Column(name="customer_phoneNum")
private String customerPhoneNum;
@Column(name="customer_password")
private String customerPassword;
}
org.springframework.beans.factory.UnsatisfiedDependencyException: ошибка создания бина с именем customerController: неудовлетворензависимость выражается через поле «сервис»;вложенное исключение - org.springframework.beans.factory.UnsatisfiedDependencyException: ошибка при создании bean-компонента с именем customerService: неудовлетворительная зависимость, выраженная через поле «repo»;вложенное исключение - org.springframework.beans.factory.BeanCreationException: ошибка создания бина с именем customerRepository: сбой вызова метода init;вложенным исключением является java.lang.IllegalArgumentException: не удалось создать запрос для метода public abstract java.util.List com.ekart.fabfeet.service.CustomerRepository.getAllCustomers ()! Не найдено свойство getAllCustomers для типа CustomerModel!
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject (AutowiredAnnotationBeanPostProcessor.javaR: -EBSE. 5.2E). 5.2.0.RELEASE] в org.springframework.beans.factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:116) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASE] в org. springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties (AutowiredAnnotationBeanPostProcessor.java:397) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEans.FeableBort.Amper,~ [весна-бобы-5.2.0.RELEASE.jar: 5.2.0.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:517) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASEfra. support.AbstractBeanFactory.lambda $ doGetBean $ 0 (AbstractBeanFactory.java:323) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASE] в org.springframework.beans.factory.support.DefaultSingletonBeanRegistry. DefaultSingletonBeanRegistry.java:222) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASE] в org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:321 ~ [spring]-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASE] в org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:202) ~ [spring-beans-5.2.0.RELEASE. jar: 5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:879) ~ [spring-beans-5.2.0.RELEASE.jar: 5.2.0.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:878) ~ [spring-context-5.2.0.RELEASE.jar: 5.2.0.RELEASE] в org.springframesu.conte. AbstractApplicationContext.refresh (AbstractApplicationContext.java:550) ~ [spring-context-5.2.0.RELEASE.jar: 5.2.0.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.reppavaServerjjvServServServServserv: 141) ~ [spring-boot-2.2.0.RELEASE.jar: 2.2.0.RELEASE] в org.springframework.boot.SpringApplication.refresh (SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar: 2.2.0.RELEASE]в org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar: 2.2.0.RELEASE] в org.springframework.boot.SpringApplication.run (SpringApplication.java: 315) [spring-boot-2.2.0.RELEASE.jar: 2.2.0.RELEASE] в org.springframework.boot.SpringApplication.run (SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE. jar: 2.2.0.RELEASE] at org.springframework.boot.SpringApplication.run (SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar: 2.2.0.RELEASE]