核心配置类:
@Configuration @AutoConfigureOrder(Integer.MAX_VALUE) @EnableAspectJAutoProxy(proxyTargetClass = true) @ConditionalOnClass({HttpUtils.class}) @EnableConfigurationProperties({ BaseConfig.JWTConfig.class, BaseConfig.JWTRPCConfig.class, BaseConfig.FuluConfig.class, BaseConfig.OSSConfig.class }) @Slf4j public class StarterConfiguration { @Resource private BaseConfig.JWTConfig jwtConfig; @Resource private BaseConfig.JWTRPCConfig jwtrpcConfig; @Resource private BaseConfig.FuluConfig fuluConfig; @Resource private BaseConfig.OSSConfig ossConfig; @Bean public HttpUtils httpUtils() { return new HttpUtils(redisTemplate, jwtConfig, jwtrpcConfig, fuluConfig); } }spring.factory配置:
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.duxn.starter.config.StarterConfiguration如需添加扫描可以在StarterConfiguration中注入@Bean或者直接在spring.factory追加扫描
假设扫描类需要添加构造入参则只能在StarterConfiguration中注入@Bean
使用方式:
pom文件引入 <dependency> <groupId>com.duxn</groupId> <artifactId>duxn-spring-boot-starter</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> yml文件配置 fulu: ichnbUrl: isCache: isAuth: jwt: issuer: rpc: secret: url: oss: accessId: accessKey: endPoint: nameSpace: packages:至此:一个自己的starer已完成!
福禄·研发中心 福小雄