企业营销型网站建设哪家好,手工制作书签简单漂亮,电商网站是获取流量,龙港做网站店铺下面的代码示例演示了如果当前服务的启动环境是windows系统#xff0c;则不会注入Tyc这个类的实例到spring容器#xff0c;如果不是windows系统#xff0c;则会注入Tyc这个类的实例到spring容器
Service
Conditional(value WindowsPlatformCondition.class)
public class …下面的代码示例演示了如果当前服务的启动环境是windows系统则不会注入Tyc这个类的实例到spring容器如果不是windows系统则会注入Tyc这个类的实例到spring容器
Service
Conditional(value WindowsPlatformCondition.class)
public class Tyc{}/*** 如果是windows平台则不会往spring中注入某些类的实例对象** author shiwentian* see org.springframework.context.annotation.Condition* since 14.7.2023**/
Component
public class WindowsPlatformCondition extends SpringBootCondition {private static final boolean IS_WINDOWS System.getProperties().getProperty(os.name).toLowerCase(Locale.ROOT).contains(windows);Overridepublic ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {if (IS_WINDOWS) {return new ConditionOutcome(false, windows platform);} else {return new ConditionOutcome(true, windows platform);}}}