Reputation: 8820
I am developing a multi-module spring boot project. My project structure look like
- myProject(parent)
- front-end
- src/main/resources
- frontend
- index.html
- rest
- src/main/java
- com.example
- MyWebApp.java
- com.example.config
- WebAppConfig.java
I am trying to configure jetty by injecting JettyServerCustomizer
as bean in WebAppConfig
as following
@Bean
public JettyServerCustomizer customizeJettyServer()
{
return new JettyServerCustomizer()
{
@Override
public void customize(final Server server)
{
ContextHandler frontEndContext = new ContextHandler();
frontEndContext.setContextPath(""); //what should be here
frontEndContext.setResourceBase("");//what should be here
ResourceHandler frontEndResourceHandler = new ResourceHandler();
frontEndResourceHandler.setWelcomeFiles(new String[] { "index.html" });
frontEndContext.setHandler(frontEndResourceHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { frontEndContext});
server.setHandler(contexts);
}
};
}
What value to set to contextPath
and ResourceBase
so that I could run my index.html which is in front-end module? How the url will looks like?
Thank you :)
Upvotes: 0
Views: 1382
Reputation: 116091
Spring Boot can serve static content for you. Instead of trying to configure Jetty, place your static content beneath src/main/resources/static
and they'll be loaded straight from the classpath.
Upvotes: 1