0

i met a problem in Studying with Spring data solr,this is my Configuration Class:

@Configuration
@EnableSolrRepositories(basePackages={"cn.likefund.solr.repository"},     multicoreSupport=true)
public class SolrContext {
static final String SOLR_HOST = "http://192.168.11.157:8080/solr";
  @Bean
  public SolrClient solrClient() {
    return new HttpSolrClient(SOLR_HOST);
  }
}

and this is my Repository:

package cn.likefund.solr.repository;
import java.util.List;
import org.springframework.data.solr.repository.SolrCrudRepository;
import cn.likefund.solr.model.Activity;
public interface ActivityRepository extends SolrCrudRepository<Activity,          String>{
List<Activity> findByName(String name);
}

when I start the application,the message in console is this

error

When I delete the method findByName in the repository,the application start with no problem, i just want to the method findByName worked,anybody know what should i do with this problem?

here is the Activity Class:

@Entity
@SolrDocument(solrCoreName ="core_activity")
public class Activity implements Serializable{
    private static final long serialVersionUID = 1566434582540525979L;
        @Id 
        @Field(value = "id")
        private String id;
        @Field(value = "CREATEDT")
        private String createdt;
        @Indexed
        @Field(value = "NAME")
        private String name;
        public String getId() {
            return id;
        }
        public void setId(String id) {
            this.id = id;
        }
        public String getCreatedt() {
            return createdt;
        }
        public void setCreatedt(String createdt) {
            this.createdt = createdt;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
}
kimi77
  • 1
  • 1

1 Answers1

0

So, obviously the CrudRepository is not created .

  • when you delete the findByName, can you manually query your repo ? (just to be sure the problem comes from the method, and not the SOLR schema)

  • have you tried to annotate annotate the method to explicitly set the query ? Something like

    @Query("NAME:?0") List findByName(String name);

jlb
  • 358
  • 3
  • 15