Hi I am trying to have both http & https protocols available in Spring Boot web service. I was following this tutorial :https://drissamri.be/blog/java/enable-https-in-sp
I had the same error 405 for POST requests. I found a way to fix it.
To enable both https and http with GET and POST I had to add the following to a @Configuration class instead of the TomcatEmbeddedServletContainerFactory as described in the post:
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return container -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) container;
Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
connector.setPort(httpPort);
containerFactory.addAdditionalTomcatConnectors(connector);
}
};
}
Hope this helps for people will have the same problem in future.