检测到不明确的字段映射问题

时间:2018-01-24 14:32:53

标签: java spring mongodb spring-boot redis

在我的spring boot mongo应用程序中获得以下异常

  

引起:org.springframework.data.mapping.model.MappingException:   检测到模糊字段映射!两个私人决赛   java.lang.reflect.Type   org.springframework.data.util.TypeDiscoverer.type和private final   java.lang.Class中   org.springframework.data.util.ClassTypeInformation.type映射到   相同的字段名称类型!使用@Field注释消除歧义!在   org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity $ AssertFieldNameUniquenessHandler.assertUniqueness(BasicMongoPersistentEntity.java:296)   〜[spring-data-mongodb-1.10.7.RELEASE.jar:na] at   org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity $ AssertFieldNameUniquenessHandler.doWithPersistentProperty(BasicMongoPersistentEntity.java:283)   〜[spring-data-mongodb-1.10.7.RELEASE.jar:na] at   org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity $ AssertFieldNameUniquenessHandler.doWithPersistentProperty(BasicMongoPersistentEntity.java:277)   〜[spring-data-mongodb-1.10.7.RELEASE.jar:na] at   org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:330)   〜[spring-data-commons-1.13.7.RELEASE.jar:na] at   org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity.verifyFieldUniqueness(BasicMongoPersistentEntity.java:157)   〜[spring-data-mongodb-1.10.7.RELEASE.jar:na] at   org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity.verify(BasicMongoPersistentEntity.java:149)   〜[spring-data-mongodb-1.10.7.RELEASE.jar:na] at   org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:332)   〜[弹簧数据公地1.13.7.RELEASE.jar:NA]

事情是这些领域(“类型”)都不在我的控制之下。需要帮助。

import org.springframework.data.mongodb.repository.MongoRepository;

import com.xyz.abc.core.model.ConfigEntity;

/**
 * 
 * @author asdasd.asdafsfg
 *
 */
public interface ConfigRepository extends MongoRepository<ConfigEntity, String> {

    public ConfigEntity findById(String id);

}

我的ConfigEntity.java看起来像这样

import java.io.Serializable;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.data.annotation.Id;
import org.springframework.data.mapping.Association;
import org.springframework.data.mongodb.core.mapping.Document;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @author vinay.shivanna
 *
 */
@Data
@NoArgsConstructor
@Document(collection="configstore")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConfigEntity implements Serializable {

    private static final long serialVersionUID = -5484736588242242417L;

    @Id
    private String id;

    @NotNull
    @JsonProperty("defaultAssociations")
    private List<Association> defaultAssociations;

    @NotNull
    @JsonProperty("profileAssociations")
    private List<Association> profileAssociations;

}

我正在使用spring mongo starter依赖

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>

Spring boot版本是1.5.7.RELEASE

我认为来自spring-data-commons-1.13.7-RELEASE jar的Association类正在扩展一个PersistentProperty类,它在内部扩展自己..像这样PersistentProperty<P extends PersistentProperty<P>>这个类有类型Property.Thats是在stacktrace ..但我真的没有解决方案。需要帮助

提前致谢

0 个答案:

没有答案