- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在安装spring-data-elasticsearch时遇到问题。我尝试了多种方法来解决此问题,但是它们没有起作用。我正在学习udemy 2016-2017年的类(class),并且正在使用spring-data-elasticsearch,spring-data-jpa依赖关系的新版本。请帮忙)
ElasticSearchConfig.java
@Configuration
@EnableElasticsearchRepositories("info.***.resume")
@ComponentScan(basePackages = {"info.***.resume.search"})
public class ElasticSearchConfig {
@Value("${elasticsearch.home}")//C:/Users/*username*/IdeaProjects/resume/elastic-search-data
private String elasticSearchHome;
@Bean
public Client client() throws UnknownHostException {
Settings settings = Settings.builder()
.put("client.transport.sniff", true)
.put("path.home", elasticSearchHome)
.put("cluster.name", "elasticsearch").build();
// return new PreBuiltTransportClient(settings)
// .addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
TransportClient client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
return client;
}
@Bean
public ElasticsearchOperations elasticsearchTemplate() throws UnknownHostException {
return new ElasticsearchTemplate(client());
}
}
public interface ProfileSearchRepository extends ElasticsearchRepository<Profile, Long> {
Page<Profile> findByObjectiveLikeOrSummaryLike(String objective, String summary, Pageable pageable);
}
@Service
@Transactional
public class ElasticSearchIndexingService {
private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchIndexingService.class);
@Value("${index.all.during.startup}")
private boolean indexAllDuringStartup;
private final ProfileSearchRepository profileSearchRepository;
private final ElasticsearchOperations elasticsearchOperations;
private final FindProfileService findProfileService;
@Autowired
public ElasticSearchIndexingService(ProfileSearchRepository profileSearchRepository, ElasticsearchOperations elasticsearchOperations, FindProfileService findProfileService) {
this.profileSearchRepository = profileSearchRepository;
this.elasticsearchOperations = elasticsearchOperations;
this.findProfileService = findProfileService;
}
@PostConstruct
private void postConstruct() {
if (indexAllDuringStartup) {
LOGGER.info("Detected index ALL command");
LOGGER.info("Clear old index");
Line38 elasticsearchOperations.deleteIndex(Profile.class);
LOGGER.info("Start index of profiles");
for (Profile p : findProfileService.findAllForIndexing()) {
profileSearchRepository.save(p);
LOGGER.info("Successful indexing of profile:{}", p.getUid());
}
LOGGER.info("Finish index of profiles");
} else {
LOGGER.info("IndexAllDuringStartup is disabled");
}
}
}
@Entity
@Table(name = "profile")
@Document(indexName = "profile")
public class Profile {
@Id
@Column(unique = true, nullable = false)
private Long id;
@Column(nullable = false)
private String uid;
@Column(name = "first_name", nullable = false, length = 50)
private String firstName;
@Column(name = "last_name", nullable = false, length = 50)
private String lastName;
@NotNull
@Size(min = 8)
@JsonIgnore
private String password;
@Column(name = "objective")
private String objective;
@Column
private String summary;
@Column(name = "birth_day")
private Date birthDay;
@Column
private String city;
@Column
private String country;
@Column
@JsonIgnore
private String email;
@Column
@JsonIgnore
private String phone;
@Column
private String info;
@Column(name = "large_photo")
@JsonIgnore
private String largePhoto;
@Column(name = "small_photo")
private String smallPhoto;
@Column(nullable = false)
@JsonIgnore
private boolean completed;
@JsonIgnore
@Column(insertable = false)
private Timestamp created;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
private List<Certificate> certificates;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@OrderBy("finishYear DESC, beginYear DESC, id DESC")
@JsonIgnore
private List<Education> educations;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@OrderBy("name ASC")
@JsonIgnore
private List<Hobby> hobbies;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
private List<Language> languages;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@OrderBy("finishDate DESC ")
private List<Practice> practices;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@OrderBy("id ASC ")
private List<Skill> skills;
@OneToMany(mappedBy = "profile", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@OrderBy("finishDate DESC ")
private List<Course> courses;
@Embedded
@JsonIgnore
private Contacts contacts;
ERROR ContextLoader Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticSearchIndexingService': Invocation of init method failed; nested exception is NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4688)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5151)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:456)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:405)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at java.security.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:352)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:248)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:388)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:391)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1262)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.exists(AbstractClient.java:1286)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.indexExists(ElasticsearchTemplate.java:715)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.deleteIndex(ElasticsearchTemplate.java:732)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.deleteIndex(ElasticsearchTemplate.java:726)
at info.windigital.resume.search.ElasticSearchIndexingService.postConstruct(ElasticSearchIndexingService.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)
... 61 more
27-Apr-2020 13:52:09.140 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
27-Apr-2020 13:52:09.141 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/resume] startup failed due to previous errors
27-Apr-2020 13:52:09.206 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [resume] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
[2020-04-27 01:52:09,227] Artifact resume:war: Error during artifact deployment. See server log for details.
最佳答案
您正在尝试创建一个deprecated transport client与Elasticsearch进行交互,而Elasticsearch正式发布了高级java rest-client,这是客户端与Elasticsearch连接的首选方法。
群集中的节点使用传输客户端进行通信,这将在同一文档中提到的8.X中完全删除:
Deprecated in 7.0.0. The TransportClient is deprecated in favour of the Java High Level REST Client and will be removed in Elasticsearch 8.0. The migration guide describes all the steps needed to migrate.
import org.springframework.beans.factory.annotation.Autowired;@Configuration
static class Config {
@Bean
RestHighLevelClient client() {
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:9200", "localhost:9201")
.build();
return RestClients.create(clientConfiguration).rest();
}
}
client
并将其用于Elasticsearch的所有操作。
关于java - NoNodeAvailableException [没有已配置的节点可用:[{#transport#-1} {OqtopIzTQmOjjLBzr2G_JA} {127.0.0.1} {127.0.0.1:9300}]],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61458106/
我从Elasticsearch得到以下错误。 `Apache Tomcat/7.0.64 - Error report HTTP Status 500 - Request processing fai
如果我没有设置大小,我将获得10次点击: SearchResponse sr = client.prepareSearch("xxx").setTypes("xxx")
尝试使用 ES 2 的 Java API 连接到 Elasticsearch 2 时出现以下错误。这是代码: Settings settings = Settings.settingsBuilder(
我正在使用SpringData将我的应用程序连接到Elastic search本地实例。当我执行常规的curl获取ES信息时,它可以正常工作,但是我无法从Springboot应用程序连接到它。 Ela
我使用 Cassandra docker 镜像,在 docker 容器上运行的 Spring Boot 服务,并使用 Datastax Java 驱动程序。 我可以使用下面的 docker compo
我尝试使用https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-get.html , Elas
Settings settings = Settings.settingsBuilder() .put("cluster.name", "logging_elastic
无法连接到我的 Elasticsearch,开始于: docker-compose up 运行命令: curl -XGET http://localhost:9200/_nodes/http?pret
我正在像这样运行 elasticsearch 图像:docker-compose.yml version: '2' services: elasticsearch: image: elas
我没有使用 Elasticssearch。我正在尝试使用 CQL 在 cassandra 中执行一些数据库操作。我正在使用线程。运行代码时,我总是在一段时间后在线程中遇到异常:com.datastax
我正在尝试从我的 Java Web 服务中的 Elastic Search 进行搜索,这是我现在的使用方式: Client client = new PreBuiltTransportClie
我正在使用 Elasticsearch 5.2 和 Spring Boot 1.5.1。我通过 Spring 应用程序中的 Java 客户端连接到它。当我在端口 9300 或 9200 上连接到它时,
我从Install Elasticsearch with Docker下载了图像 并运行以下命令来启动: docker run -p 9200:9200 -p 9300:9300 -e "discov
我正在尝试通过给定的示例之一来了解 elastic4s here 但是当我尝试通过 TcpClient.transport 连接时,我不断收到以下异常: Exception in thread "ma
我决定在一个简单的待办事项列表应用程序中尝试首次使用 elasticsearch。我关注了this video要使用该模块并且不对模块本身进行任何修改,我所做的就是创建应用程序并在 Controlle
public static void main(String[] args) throws IOException { Settings settings = ImmutableSetting
在 Google Compute Engine 上,我创建了 3 个虚拟机并在其上安装了 Elasticsearch 5.1.2。我安装了用于单播发现的GCE Discovery Plugin。 从我
我已将 elasticsearch 版本从 elasticsearch-0.90.7 更新到 elasticsearch-1.3.1,并且应用程序在 elasticsearch-0.90.7 中运行正
我正在使用带防护罩和传输 Java 客户端的弹性云(以前发现的)。与 ES 通信的应用程序运行在 heroku 上。我正在使用一个节点在暂存环境中运行压力测试 { "cluster_name"
我正在运行 Elasticsearch v. 2.3.2 ,使用 Java 7。以下是 curl http://172.31.11.83:9200 的打印输出: { "name" : "ip-17
我是一名优秀的程序员,十分优秀!