借助gitee仓库构建私有图床
架构和准备具体实现细节仓库和源码地址服务端yaml配置启动类同步git 云图演示借助gitee仓库构建私有图床架构和准备创建gitee服务端仓库创建gitee图床仓库日常图片存储gitee仓库通过git提交保障本地电脑和云上备份双份创建spring-boot服务端应用实现预览图片路径为gitee图床创建spring-boot客户端应用实现远程服务端同步git pull命令部署服务通过nginx域名代理服务端部署具体实现细节仓库和源码地址gitee 图片仓库[https://gitee.com/kcnf_open/wiki]gitee 服务端仓库[https://gitee.com/kcnf_open/kcnf-wiki]服务端dependencies dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId /dependency /dependenciesyaml配置#app server: port: 8086 servlet: context-path: / #spring spring: main: allow-bean-definition-overriding: true devtools: restart: enabled: false profiles: active: dev web: resources: static-locations: file:${IMAGE_BASE_PATH:/data/wiki}/, classpath:/static/启动类package com.jysemel.kcnf; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.EnableScheduling; /** * author jysemel */ Slf4j EnableScheduling SpringBootApplication public class WikiApplication implements CommandLineRunner { Autowired private ApplicationContext context; public static void main(String[] args) { log.info(砍材农夫 开始启动........................................); SpringApplication.run(WikiApplication.class, args); log.info(砍材农夫 启动成功........................................); } Override public void run(String... args) throws Exception { // 更简单的方法直接输出配置值 String path context.getEnvironment().getProperty(IMAGE_BASE_PATH); log.info( IMAGE_BASE_PATH {}, path); log.info( static-locations {} , context.getEnvironment().getProperty(spring.web.resources.static-locations)); } }同步git 云图package com.jysemel.kcnf.controller; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; Slf4j RestController public class GitController { Autowired private ApplicationContext context; SneakyThrows GetMapping(/admin/pull) public String pull() throws IOException { String path context.getEnvironment().getProperty(IMAGE_BASE_PATH); log.info( IMAGE_BASE_PATH {}, path); Process process Runtime.getRuntime().exec(git -C path pull); int code process.waitFor(); return code 0 ? success : failed; } }演示
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2574005.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!