如何在Spring Boot应用程序中配置我的(嵌入式)Tomcat会话超时?
public class SessionListener implements HttpSessionListener{
@Override
public void sessionCreated(HttpSessionEvent se) {
se.getSession().setMaxInactiveInterval(5*60);
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
}}
Run Code Online (Sandbox Code Playgroud)
我有一个SessionListener,但我不知道在哪个类中我必须将此监听器添加到Context.
我期待将Elasticsearch集成到Spring Boot Web应用程序中.以下是我创建传输客户端的配置:
@Configuration
public class ElasticsearchConfig {
private TransportClient client;
@Bean
public TransportClient client() throws UnknownHostException{
Settings settings = Settings.builder()
.put("client.transport.nodes_sampler_interval", "5s")
.put("client.transport.sniff", false)
.put("transport.tcp.compress", true)
.put("cluster.name", "clusterName")
.put("xpack.security.transport.ssl.enabled", true)
.build();
client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
return client;
}
Run Code Online (Sandbox Code Playgroud)
当我启动项目时,我得到以下错误,我不知道为什么:
java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPlugin
Run Code Online (Sandbox Code Playgroud)
我忘了添加依赖项吗?
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.1.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
希望你能帮我