💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 一、概述 这里介绍系统启动的时候,能够被自动加载的业务机制,一些需要在系统启动的时候就要加载的业务逻辑,可以使用这个机制来实现; 平台提供了两种自动启动机制,以下分别介绍; ## 二、方案一 继承AutoStartWhenBooting; ``` @Service public class ThirdPartyImplementationLoader extends AutoStartWhenBooting { public static List<ThirdPartyApiMeta> thirdPartyApiList = new ArrayList(); @Override public void doSomething() { Set<Class> classes = ClassUtil.getClassesInRayPackagesExtendsFrom(ThirdPartySupport.class); for (Class clazz : classes) { ThirdPartyApiMeta meta = new ThirdPartyApiMeta(); ThirdPartyApiDefinition tpad = (ThirdPartyApiDefinition) clazz.getAnnotation(ThirdPartyApiDefinition.class); meta.setApiName(tpad.name()); meta.setClazzName(clazz.getCanonicalName()); meta.setParaNames(tpad.constructorParamterNames()); thirdPartyApiList.add(meta); } } } ``` 1、用@Service注解,继承自AutoStartWhenBooting; 2、实现自己的doSomething()方法即可; ## 三、方案二 实现接口:org.ray.framework.core.convention.processor.StartUpAction,并注解为Bean; ``` @Component public class Test implements StartUpAction { @Autowired private CardPooledQuotaDao cardPooledQuotaDao; @Override public void doAction(Rayframework rayframework) { String now = DateUtil.getDateStr(100); List<CardPooledQuota> quotaList = cardPooledQuotaDao.findByCardIdAndReviseValidTimeLessThanEqualAndReviseInvalidTimeGreaterThanEqualOrderByCreateTimeAscPackageTypeAsc(59847, now, now); System.out.print(quotaList.size()); } } ```