springboot path problem

1. Some common web paths in springboot

  1. The index file in the resources folder is accessed by default when the project starts
  2. The default project path of springboot is localhost:8080
  3. The default access path of swagger is 127.0.0.1:8090/swagger-ui.html
  4. The default'/' (root path) in tymleaf is resources
  5. The default static resources (css, js) in tymleaf are in the /resources/static folder
  6. The classpath in the yml file refers to the resources folder
  7. webjars/ is under the /resources/static folder by default
  8. All **/favicon.ico (default icon) are found under the static resource file
  9. The default startup port is 8080
  10. The pages in thymleaf are by default in the template under resources

2. How to modify

  1. Modify the built-in sevlet container
server.servlet.context-path=/sw		#修改访问路径
spring.application.name=sw			#修改项目名称
server.port=8090								#修改访问端口
  1. Refurbished 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. Modify the path of thymleaf
spring.thymeleaf.prefix=跟路径问resources

Guess you like

Origin blog.csdn.net/fuzekun/article/details/105049299