Spring-Data-Elastic Search and Spring-Data-Cassandra Having Issues with MapId

谁说胖子不能爱 提交于 2020-03-03 07:45:06

问题


I am trying to have Spring-Data-Cassandra and Spring-Data-Elasticsearch work together. Below is the problem which I am facing.

org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.format.support.FormattingConversionService]: Factory method 
'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'personRepository': Invocation of init method failed; 
nested exception is java.lang.IllegalArgumentException: Unsuppored ID type interface 
org.springframework.data.cassandra.repository.MapId

My Repositories interfaces are in different packages and I have marked the with

@EnableElasticsearchRepositories(basePackages = "com.mycompany.mp.search.repo") 

and

@EnableCassandraRepositories(basePackages = { "com.infy.mycompany.repository" })

I have used MappingCassandraConverter and org.springframework.data.elasticsearch.core.DefaultEntityMapper. The elasticsearch template is init like this new ElasticsearchTemplate(client, new DefaultEntityMapper());

My Person object looks like this.

import org.springframework.data.cassandra.mapping.Table;
/**
* Created by allahbaksh_asadullah on 01/11/16.
*/
@Table(value = "person")
@Document(indexName = "person")
public class Person implements Serializable  {

    private static final long serialVersionUID = 1L;

    @Id
    private Long id;

    private String firstName;

    private String lastName;
    //Getters and Setters
}

If I don't mark my Person.java with the @Document annotation things works fine but ElasticSearch will not work then.

What is the best way make it work?

来源:https://stackoverflow.com/questions/40353603/spring-data-elastic-search-and-spring-data-cassandra-having-issues-with-mapid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!