gpt4 book ai didi

java - org.springframework.data.mapping.PropertyReferenceException 我需要更改什么?

转载 作者:行者123 更新时间:2023-12-02 13:10:52 31 4
gpt4 key购买 nike

异常的文本显示“没有找到类型的属性 fid”(原文如此!),我尝试用谷歌搜索,但一无所获。可能它代表“功能 ID”,但我不确定它到底发生了什么。我如何解决它?我的类(class)有问题吗?

我的属性类:

@Entity
@Table(name = "LAB3_ATTRIBUTES")
public class Attribute {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "ATTR_ID", length = 10, nullable = false)
private Integer id;

@Column(name = "NAME")
private String name;

@ManyToOne
@JoinColumn(name = "OBJECT_TYPE_ID", referencedColumnName = "OBJECT_TYPE_ID")
private ObjectType objectType;

@OneToMany(mappedBy = "attribute", cascade = CascadeType.ALL)
private List<Parameter> parameters;

public Attribute() {
}

public Attribute(String name, ObjectType objectType) {
this.name = name;
this.objectType = objectType;
}

public Integer getId() {
return id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public ObjectType getObjectType() {
return objectType;
}

public void setObjectType(ObjectType objectType) {
this.objectType = objectType;
}

public List<Parameter> getParameters() {
return parameters;
}

public void setParameters(List<Parameter> parameters) {
this.parameters = parameters;
}
}

我的AttributeRepository接口(interface):

public interface AttributeRepository extends JpaRepository<Attribute, Integer > {

Attribute findById(int id);
List<Attribute> findByName(String name);
List<Attribute> fidByObjectType(ObjectType objectType);
}

我的AttributeService接口(interface):

public interface AttributeService {
void save(Attribute attribute);
Attribute findById(int id);
List<Attribute> findByName(String name);
List<Attribute> findByObjectType(ObjectType objectType);
}

我的 AttributeServiceImpl 类:

@Service
public class AttributeServiceImpl implements AttributeService {

@Autowired
private AttributeRepository attributeRepository;

public void save(Attribute attribute) {
attributeRepository.save(attribute);
}
public Attribute findById(int id) {
return attributeRepository.findById(id);
}
public List<Attribute> findByName(String name) {
return attributeRepository.findByName(name);
}
public List<Attribute> findByObjectType(ObjectType objectType) {
return attributeRepository.fidByObjectType(objectType);
}
}

我的异常(exception):

    <15 ìàÿ 2017, 8:49:22,550 AM EEST> <Error> <org.springframework.web.context.ContextLoader> <BEA-000000> <Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:316)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
Truncated. see log file for complete stacktrace
>
<15 ìàÿ 2017, 8:49:22,561 AM EEST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:316)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
Truncated. see log file for complete stacktrace
>
<15 ìàÿ 2017, 8:49:22,608 AM EEST> <Warning> <EclipseLink> <BEA-2005000> <2017-05-15 08:49:22.592--No partition instance associated with current SessionManager instance.>
<15 ìàÿ 2017, 8:49:22,614 AM EEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "4217989485440" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute"
weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
Truncated. see log file for complete stacktrace
>
<15 ìàÿ 2017, 8:49:22,618 AM EEST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application "packear_ear" on [partition-name: DOMAIN].>
<15 ìàÿ 2017, 8:49:22,662 AM EEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "packear_ear".>
<15 ìàÿ 2017, 8:49:22,663 AM EEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute:org.springframework.data.mapping.PropertyReferenceException:No property fid found for type com.shop.database.entities.Attribute
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
Truncated. see log file for complete stacktrace

最佳答案

您在这行中有一个拼写错误:

List<Attribute> fidByObjectType(ObjectType objectType);

应该是

List<Attribute> findByObjectType(ObjectType objectType);

由于拼写错误,Spring Data 正在寻找名为“fid”的属性,该属性当然不存在。

关于java - org.springframework.data.mapping.PropertyReferenceException 我需要更改什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43969479/

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