Java Code Examples for org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory#setContextPath()

The following examples show how to use org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory#setContextPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayuiAdminStartUp.java    From layui-admin with MIT License 6 votes vote down vote up
@Bean
public ServletWebServerFactory servletContainer() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    tomcat.addInitializers(new ServletContextInitializer(){
        @Override
        public void onStartup(ServletContext servletContext) throws ServletException {
            XmlWebApplicationContext context = new XmlWebApplicationContext();
            context.setConfigLocations(new String[]{"classpath:applicationContext-springmvc.xml"});
            DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
            ServletRegistration.Dynamic dispatcher = servletContext
                    .addServlet("dispatcher", dispatcherServlet);

            dispatcher.setLoadOnStartup(1);
            dispatcher.addMapping("/");
        }
    });
    tomcat.setContextPath("/manager");
    tomcat.addTldSkipPatterns("xercesImpl.jar","xml-apis.jar","serializer.jar");
    tomcat.setPort(port);

    return tomcat;
}
 
Example 2
Source File: HomeController.java    From odo with Apache License 2.0 6 votes vote down vote up
@Bean
public ServletWebServerFactory servletContainer() throws Exception {
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();

    int apiPort = Utils.getSystemPort(Constants.SYS_API_PORT);
    factory.setPort(apiPort);
    factory.getSession().setTimeout(Duration.ofMinutes(10));
    factory.setContextPath("/testproxy");
    baseDirectory = new File("./tmp");
    factory.setBaseDirectory(baseDirectory);
    List<TomcatConnectorCustomizer> cs = new ArrayList();
    cs.add(tomcatConnectorCustomizers());
    factory.setTomcatConnectorCustomizers(cs);

    if (Utils.getEnvironmentOptionValue(Constants.SYS_LOGGING_DISABLED) != null) {
        HistoryService.getInstance().disableHistory();
    }
    return factory;
}
 
Example 3
Source File: WebMvcCustomizer.java    From spring-boot-source-analysis-code with Apache License 2.0 4 votes vote down vote up
@Override
public void customize(TomcatServletWebServerFactory factory) {
    factory.setPort(9090);
    factory.setContextPath("/demo");
}