I have a working spring mvc created with spring boot and embeded tomcat. Now I would like to change some default setting of the tomcat i.e. port setSessionTimeout etc. from the spring boot readme (http://projects.spring.io/spring-boot/docs/spring-boot/README.html) I have copied the example
i.e. created a class that looks like the one below: now when i start my spring boot (building jar not war) i am getting the following error
Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to multiple EmbeddedServletContainerFactory beans : servletContainer,tomcatEmbeddedServletContainerFactory
I understand that there are two EmbeddedServletContainerFactory's created but why is that I thought that whatever bean i declare of type EmbeddedServletContainerFactory it should override the existing default one. If i rename the EmbeddedServletContainerFactory from servletContainer() to tomcatEmbeddedServletContainerFactory() the error is gone however the port i set is not 8888 anymore but 8080 the default one. And it seems that it is working but not accepting the my customer settings i.e. port 8888
import java.util.concurrent.TimeUnit;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TomcatEmbeded {
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.setPort(8888);
factory.setSessionTimeout(5, TimeUnit.MINUTES);
//factory.addErrorPages(new ErrorPage(HttpStatus.404, "/notfound.html");
return factory;
}
}