房建设计网站好,医院网站怎么做优化排名,在哪修改网站关键词,seo如何网站正常更新下面的代码示例演示了如果当前服务的启动环境是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);}}}