All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.knife4j.ServletKnife4jAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.knife4j;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootConfiguration
@ConditionalOnWebApplication(type = Type.SERVLET)
@ComponentScan(basePackages = {"com.github.xiaoymin.knife4j.spring.plugin"})
@ConditionalOnProperty(name = "knife4j.enable", havingValue = "true")
@EnableConfigurationProperties(value = {com.github.xiaoymin.knife4j.spring.configuration.Knife4jProperties.class})
@ConditionalOnClass(value = {com.github.xiaoymin.knife4j.core.extend.OpenApiExtendSetting.class, com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver.class})
public class ServletKnife4jAutoConfiguration  implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
            /*配置knife4j 显示文档 */
            //registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("api.html").addResourceLocations("classpath:/META-INF/resources/");

            /** 公共部分内容 */
            registry.addResourceHandler("/webjars/**")
                    .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy