spring-data-solr java.lang.IllegalArgumentException: 不是托管类型
spring-data-solr java.lang.IllegalArgumentException: Not a managed type
我正在使用 spring-data-solr,但我无法让它工作 :(..
我还是 spring 的新手,我想我设置了所有东西,你能帮我吗。
非常感谢
***************************
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() {
谢谢
尝试按照下面的代码片段所示扫描您的基本包。
此外,@EnableSolrRepositories
应该指向存储库的确切位置 class 而不是 ...repositories.solr.*
你可以 com.dateup.repositories.solr
。
@Configuration
@ComponentScan(basePackages = "com.dateup")
@EnableSolrRepositories(basePackages = {"com.dateup.repositories.solr"}, multicoreSupport = true)
public class SearchContext {
}
我正在使用 spring-data-solr,但我无法让它工作 :(..
我还是 spring 的新手,我想我设置了所有东西,你能帮我吗。
非常感谢
***************************
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() {
谢谢
尝试按照下面的代码片段所示扫描您的基本包。
此外,@EnableSolrRepositories
应该指向存储库的确切位置 class 而不是 ...repositories.solr.*
你可以 com.dateup.repositories.solr
。
@Configuration
@ComponentScan(basePackages = "com.dateup")
@EnableSolrRepositories(basePackages = {"com.dateup.repositories.solr"}, multicoreSupport = true)
public class SearchContext {
}