springboot 路径问题

1.一些springboot中常见的web路径

  1. 项目启动默认访问 resources文件夹下的index文件
  2. springboot 默认的项目路径为 localhost:8080
  3. swagger 的默认访问路径是 127.0.0.1:8090/swagger-ui.html
  4. tymleaf中的默认的 ‘/‘(根路径)是resources
  5. tymleaf 中的默认 静态资源(css, js)在 /resources/static文件夹下
  6. 在yml 文件中的classpath指的是resources 文件夹
  7. webjars/默认在/resources/static文件夹下
  8. 所有的 **/favicon.ico (默认的图标) 都是在静态资源文件下找
  9. 默认的启动端口是8080
  10. thymleaf中的页面默认在resources 下的template中

2.如何修改

  1. 修改内置sevlet的容器
server.servlet.context-path=/sw		#修改访问路径
spring.application.name=sw			#修改项目名称
server.port=8090								#修改访问端口
  1. 修改swagger-ui.html
    @Bean
    public Docket createRestApi() {
    
    
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .host("ap");			#这个进行修改访问地址
                .select()
                //controller的目录
                .apis(RequestHandlerSelectors.basePackage("com.swagger.api"))
                .paths(PathSelectors.any())
                .build();
    }
	//用来创建该Api的基本信息(这些基本信息会展现在文档页面中)
    private ApiInfo apiInfo() {
    
    
        return new ApiInfoBuilder()
                .title("swagger")
                .description("http://www.baidu.com/")
                .termsOfServiceUrl("http://www.baidu.com/")
                .version("1.0")
                .build();
    }
  1. 修改thymleaf 的路径
spring.thymeleaf.prefix=跟路径问resources

猜你喜欢

转载自blog.csdn.net/fuzekun/article/details/105049299
今日推荐