基于springBoot框架开发短视频去水印源码项目+IntelliJ IDEA运行测试+本地实现功能

本文档介绍了如何基于SpringBoot框架开发短视频去水印项目,详细步骤包括在IntelliJ IDEA中创建Maven项目,设置项目结构,编写源码,配置application.yml文件,以及运行和测试。项目包含TextUtilde、VideoController、VideoModel等组件,实现了去水印功能。同时,提到了本地功能实现和未来云服务器部署的计划。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一:创建一个springboot的maven项目包

新建:File–new–project
下载1.8jdk 以及 Maven 我这里下载的是 Maven 3.6.1
在这里插入图片描述
GroupID是项目组织唯一的标识符:一般书写格式:com.公司.项目名
ArtifactID就是项目的唯一的标识符:一般书写格式:项目名
在这里插入图片描述
需要提前配置maven 还要修改settings.xml文件 这里就不多说了
在这里插入图片描述

在这里插入图片描述

二:src里面写我们的去水印源码

在这里插入图片描述
这是我new好的文件 在这里我就不多做解释了
在JsonUtil这个java文件里代码内容如下

package com.rjt.common.util;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
public class JsonUtil {
	/**
	 * 将json格式化为字符串,然后根据key取值
	 * @param jsonStr
	 * @param key
	 * @return
	 */
	public static String getJsonValue(String jsonStr,String key) {
		 if(StringUtils.isEmpty(jsonStr) || StringUtils.isEmpty(key)) {
			 return "";
		 } 
		 if(key.indexOf(".")==-1) {
			 if(key.indexOf("[")!=-1) {
				 int num =Integer.parseInt(TextUtil.getSubString(key, "[", "]"));
				 key=key.substring(0, key.indexOf("["));
				return  JSON.parseObject(jsonStr).getJSONArray(key).getString(num);
			 }else {
				 return JSON.parseObject(jsonStr).getString(key);
			 }
		 }else {
			 String[] keys = key.split("\\.");
			 for(int i=0;i<keys.length;i++) {
				 String tempKey=keys[i];
				 if(tempKey.indexOf("[")!=-1) {
					 int num =Integer.parseInt(TextUtil.getSubString(tempKey, "[", "]"));
					 tempKey=tempKey.substring(0, keys[i].indexOf("["));
					 jsonStr=JSON.parseObject(jsonStr).getJSONArray(tempKey).getString(num);
				 }else {
					 jsonStr=JSON.parseObject(jsonStr).getString(tempKey);
				 }
			 }
			return jsonStr;
		 }
	}
}

TextUtilde

package com.rjt.common.util;
import blade.kit.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Random;
public class TextUtil {
	private static Logger logger = LoggerFactory.getLogger(TextUtil.class);
	/**
	 * 取两个文本之间的文本值
	 * 
	 * @param text
	 * @param left
	 * @param right
	 * @return
	 */
	public static String getSubString(String text, String left, String right) {
		String result = "";
		int zLen;
		if (left == null || left.isEmpty()) {
			zLen = 0;
		} else {
			zLen = text.indexOf(left);
			if (zLen > -1) {
				zLen += left.length();
			} else {
				zLen = 0;
			}
		}
		int yLen = text.indexOf(right, zLen);
		if (yLen < 0 || right == null || right.isEmpty()) {
			yLen = text.length();
		}
		result = text.substring(zLen, yLen);
		return result;
	}
	/**
	 * 获取ip
	 * 
	 * @param request
	 * @return
	 */
	public static String getRemortIP(HttpServletRequest request) {
	     String ip = request.getHeader("x-forwarded-for"); 
       if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {  
           // 多次反向代理后会有多个ip值,第一个ip才是真实ip
           if( ip.indexOf(",")!=-1 ){
               ip = ip.split(",")[0];
           }
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getHeader("Proxy-Client-IP");  
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getHeader("WL-Proxy-Client-IP");  
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getHeader("HTTP_CLIENT_IP");  
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getHeader("HTTP_X_FORWARDED_FOR");  
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getHeader("X-Real-IP");  
       }  
       if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
           ip = request.getRemoteAddr();  
       } 
       return ip;  
   }
	/**
	 * 根据ip获取地址
	 * 
	 * @param
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String getPlace(String ip) throws UnsupportedEncodingException {
		if (ip.indexOf(", ") != -1) {
			ip = ip.split(", ")[1];
		}
		String url = "https://ip.cn/index.php?ip=" + ip;
		HttpRequest request = HttpRequest.get(url, true).header("User-Agent",
				"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0");
		String res = request.body();
		String place = TextUtil.getSubString(res, "置:<code>", "</code></p><p>");
		request.disconnect();
		return place;
	}
	/**
	 * 根据地址获取纬度
	 * 
	 * @param
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String getWd(String place) throws UnsupportedEnco
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值