Apex是一个简单的依赖注入库
通过 Maven
或 Gradle
创建一个项目,因为还未上传到Maven中心仓库,所以目前暂时通过clone代码进行安装
git clone https://github.com/AquiverV/apex.git
cd apex
mvn clean install
通过 Maven
安装:
<dependency>
<groupId>org.apex</groupId>
<artifactId>apex</artifactId>
<version>1.0</version>
</dependency>
final Apex apex = Apex.of();
final String scanPath = "org.example";
final List<Class<? extends Annotation>> typeAnnotations = new ArrayList<>();
//添加需要自动扫描的注解
typeAnnotations.add(Path.class);
typeAnnotations.add(RouteAdvice.class);
typeAnnotations.add(RestPath.class);
typeAnnotations.add(WebSocket.class);
typeAnnotations.add(Singleton.class);
typeAnnotations.add(ConfigBean.class);
typeAnnotations.add(PropertyBean.class);
typeAnnotations.add(Scheduled.class);
apex.typeAnnotation(typeAnnotations);
//添加扫描路径
apex.packages().add(scanPath);
apex.mainArgs(aquiver.mainArgs());
//通过instance方法获取ApexContext对象
ApexContext apexContext = ApexContext.instance();
//初始化
apexContext.init(apex);
Copyright (c) 2020-present, Yi (Ever) Wang