Spring Boot url端点

时间:2015-12-13 02:16:31

标签: java spring-mvc spring-boot

我试图创建一个Spring Boot项目,其端点是localhost:8080 /而不是localhost:8080 / projectname /

我目前的mvcinitializer如下:

public class SpringMvcInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[] { SpringRootConfig.class };
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] { ThymeleafConfig.class };
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }

    @Override 
    protected Filter[] getServletFilters() {
        return new Filter[] {new EmailVerificationFilter()};
    }
}
无论如何,我是否能够实现上述行为?

1 个答案:

答案 0 :(得分:1)

您只需在application.properties文件中使用设置server.contextPath

server.contextPath=/projectname