@AutoConfigureAfter(SomeOtherAutoConfiguration.class) @ConditionalOnProperty(prefix = "example", value = "enabled", havingValue = "true", matchIfMissing = true) public class ExampleAutoConfiguration { @Autowired private ExampleProperties properties; @Bean @ConditionalOnMissingBean public ExampleService exampleService() { return new ExampleService(properties.getSomeValue()); } } @ConfigurationProperties(prefix = "example") public class ExampleProperties { private String someValue; // Getter and Setter methods } public class ExampleService { private String value; public ExampleService(String value) { this.value = value; } public String getValue() { return value; } }


上一篇:
下一篇:
切换中文