添加license

This commit is contained in:
mass
2026-05-18 09:21:57 +08:00
15 changed files with 887 additions and 9 deletions
@@ -1,5 +1,7 @@
package com.ruoyi;
import com.ruoyi.common.utils.license.LicenseException;
import com.ruoyi.common.utils.license.LicenseUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -20,9 +22,49 @@ public class RuoYiApplication
{
// System.setProperty("spring.devtools.restart.enabled", "false");
ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args);
verifyLicense(application.getEnvironment());
printStartupMessage(application.getEnvironment());
}
/**
* 校验 License 授权,校验失败则退出程序。
*/
private static void verifyLicense(Environment env)
{
String licensePath = env.getProperty("af.license.path");
if (licensePath == null || licensePath.trim().isEmpty())
{
System.err.println("\n========================================");
System.err.println(" License 授权校验失败");
System.err.println("========================================");
System.err.println("错误:未配置 License 文件路径(af.license.path)");
System.err.println("请在 application.yml 中配置 af.license.path 参数");
System.err.println("========================================\n");
System.exit(1);
}
try
{
LicenseUtils.verify(licensePath);
}
catch (LicenseException e)
{
System.err.println("\n========================================");
System.err.println(" License 授权校验失败");
System.err.println("========================================");
System.err.println("错误:" + e.getMessage());
System.err.println();
System.err.println("解决方法:");
System.err.println("1. 在目标服务器上运行 License 生成工具:");
System.err.println(" java -cp ruoyi.jar com.ruoyi.common.utils.license.LicenseGenerator");
System.err.println("2. 将生成的 license.lic 文件路径配置到 application.yml 的 af.license.path");
System.err.println("========================================\n");
System.exit(1);
}
}
/**
* 打印启动成功提示,包含端口与接口文档地址。
*/
@@ -128,6 +128,8 @@ referer:
# 自动充值业务配置
af:
license:
path: D:\license\license.lic
rechargeUrl: https://www.douyin.com/pay
weidian:
wdToken: e96014f3