class file for org.apache.solr.client.solrj.embedded.EmbeddedSolrServer not found

1.3k views Asked by At

I would like to set up an embedded Solr server into my existing web application. But I'm failing already at creating the beans:

[ERROR] /home/danny/workspace/example/src/main/java/com/example/config/MainConfig.java:[76,45] cannot access org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
  class file for org.apache.solr.client.solrj.embedded.EmbeddedSolrServer not found

This is my maven dependency (I would like to use the embedded server version as mentioned in the note section here):

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-solr</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

And this is my Configuration class (necessary parts of it):

@Configuration
@ComponentScan(basePackages = "com.example", excludeFilters = { @ComponentScan.Filter(Configuration.class) })
@EnableSolrRepositories
public class MainConfig {
    @Bean
    public SolrServer solrServer() {
        EmbeddedSolrServerFactory factory = new EmbeddedSolrServerFactory("classpath:com/example/solr");
        return factory.getSolrServer(); // Eclipse tells: The type org.apache.solr.client.solrj.embedded.EmbeddedSolrServer cannot be resolved. It is indirectly referenced from required .class files
    }

    @Bean
    public SolrOperations solrTemplate() {
        return new SolrTemplate(solrServer());
    }
}
1

There are 1 answers

1
Frederic Close On BEST ANSWER

your are missing solr dependency itself

<dependency>
    <groupId>org.apache.solr</groupId>
    <artifactId>solr-core</artifactId>
    <version>THE_VERSION_YOU_WANT_TO_USE</version>
</dependency>