我遇到Spring Data Elasticsearch的问题。我像这样配置elasticsearch:
@Configuration
@EnableJpaRepositories(basePackages = {"org.project.repositories"})
@EnableElasticsearchRepositories(basePackages = "org.project.repositorieselastic")
@EnableTransactionManagement
public class PersistenceContext {
@Bean
public ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchTemplate(client());
}
@Bean
public Client client(){
Settings settings = ImmutableSettings.settingsBuilder()
// Setting "transport.type" enables this module:
.put("cluster.name", "elasticsearch")
.put("client.transport.ignore_cluster_name", false)
.build();
TransportClient client= new TransportClient(settings);
TransportAddress address = new InetSocketTransportAddress("127.0.0.1", 9300);
client.addTransportAddress(address);
return client;
}
}
我的回购看起来像。
@Repository()
public interface UserFavoriteElasticRepo extends ElasticsearchRepository<UserFavorite, Long> {
}
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.project.repositorieselastic.UserFavoriteElasticRepo org.project.services.elastic.FavoriteIndexerService.elasticRepo; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userFavoriteElasticRepo': Invocation of init method failed; nested exception is java.lang.AbstractMethodError
看起来没有生成实现。但我不知道在哪里调查。我尝试使用一个包并使用它 - https://github.com/izeye/spring-boot-throwaway-branches/commit/874ccba09189d6ef897bc430c43b6e3705404399但没有成功。
答案 0 :(得分:1)
我解决了在pom文件中添加此问题的问题
node {
stage ('Checkout')
{
checkout scm
}
stage ('Build')
{
bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
}
stage ('Warnings')
{
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'MSBuild']], unHealthy: ''])
}
}
答案 1 :(得分:0)
我使用spring-data-elasticsearch得到了相同的异常。 但是当我在存储库中声明新方法时抛出了异常: 例如:
public interface UserFavoriteElasticRepo extends ElasticsearchRepository<UserFavorite, Long> {
Page<UserFavorite> findBySomeProperty(String propertyValue, Pageable pageable);
}
由于spring-data-elasticsearch,spring-data-commons版本,它被淘汰了。函数声明已更改:org.springframework.data.repository.query.QueryLookupStrategy.resolveQuery - 它导致异常。
对于spring-data-elasticsearch版本2.0.0.RELEASE,你必须使用版本为1.12.0的spring-data-commons。
如果你的项目中有spring-data-jpa,它也会使用spring-data-commons。对于spring-data-jpa v1.9.0.RELEASE,spring-data-commons是v1.11.0.RELEASE
您能提供您正在使用的弹簧框架和版本吗?另外如果你可以整个堆栈跟踪,它会有帮助吗?