SpringBoot访问外部文件配置

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    private final static Logger LOGGER = LoggerFactory.getLogger(WebConfig.class);
    /**
     * 访问外部文件配置
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String filePath = ConfigConstants.getFileDir();
        LOGGER.info("Add resource locations: {}", filePath);
        registry.addResourceHandler("/Contract/**").addResourceLocations("classpath:/META-INF/resources/","classpath:/resources/","classpath:/static/","classpath:/public/","file:" + filePath);
        super.addResourceHandlers(registry);
    }
}

协议://IP:端口/项目名/Contract/**.*

上一篇:数控机床面板解密


下一篇:编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值 Linux0304