我正在使用spring-data-solr,但我无法使其工作:(..
我还是刚接触春天,我想我设置了所有的东西,请你帮我。
非常感谢
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userSearchResultSolrRepository in com.dateup.models.solr.StartupSync required a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' that could not be found.
Action:
Consider defining a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' in your configuration.
这是我的代码:
我设置了依赖
...
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
....
@Configuration
@EnableSolrRepositories(basePackages = {"com.dateup.repositories.solr.*"}, multicoreSupport = true)
public class SearchContext {
}
import org.joda.time.LocalDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.solr.core.mapping.Indexed;
import org.springframework.data.solr.core.mapping.SolrDocument;
@SolrDocument(solrCoreName = "collection1")
public class UserSearchResultSolr {
@Id
@Indexed
public Long id;
@Indexed
public String name;
.....
}
import org.springframework.data.solr.repository.SolrCrudRepository;
public interface UserSearchResultSolrRepository extends SolrCrudRepository<UserSearchResultSolr, String> {
}
@Component
public class StartupSync {
@Autowired
private UserRepository m_userRepository;
@Autowired
private UserSearchResultSolrRepository userSearchResultSolrRepository;
@PostConstruct
public void syncSolr() {
谢谢
答案 0 :(得分:1)
尝试搜索扫描基础包,如下面的代码snipet所示。
此外,if(kind == UICollectionElementKindSectionHeader)
应指向您的存储库类的确切位置,而不是@EnableSolrRepositories
您可以...repositories.solr.*
。
com.dateup.repositories.solr