升级到 Spring Boot 版本 1.3.0.RELEASE 后,我在尝试启动时看到以下失败。
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'productRepository': Invocation of init
method failed; nested exception is
org.springframework.data.mapping.PropertyReferenceException: No
property true found for type boolean! Traversed path: Product.active.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 64 more Caused by: org.springframework.data.mapping.PropertyReferenceException: No property true found for type boolean! Traversed path: Product.active.
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
这是导致问题的代码的相关片段。没有对任何存储库或数据模型进行任何更改。
public interface ProductRepository extends JpaRepository<Product, Long> {
List<Product> findByActiveTrue_productInfoActiveTrue();
}
@Entity
@DiscriminatorValue(value = "0")
public class Product extends BaseProduct {
public boolean isSpecial() {
return special;
}
public void setSpecial(boolean special) {
this.special = special;
}
}
@Entity(name = "products")
@DiscriminatorColumn(name = "matchtype", discriminatorType = DiscriminatorType.INTEGER)
public abstract class BaseProduct implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "isspecial")
protected boolean special;
@Id
@GeneratedValue
@Column(name = "productid")
private Long productId;
@Column(name = "active")
private boolean active;
@OneToMany(mappedBy = "productId", fetch = FetchType.EAGER)
private Set<ProductInfo> productInfo;
@Entity(name = "products_ranges")
public static class ProductInfo {
@Id
@Column(name = "prodrangeid")
private Long id;
@Column(name = "product_id")
private Long productId;
@Column(name = "active")
private boolean active;
}
任何有关此问题的帮助将不胜感激。我尝试回到旧版本的 spring-data-common 但这不适用于新的 spring-data-jpa。
谢谢!