Micronaut provides out-of-the-box integrations with a lot of tools and third-party libraries: Consul, Eureka, Hibernate, Kafka, Mongo, Micrometer, Zipkin, Hystrix, Swagger,... But sometimes this is not enough and you need to integrate with a new one.
In this talk, we will discuss the different options that we have to create a new configuration for Micronaut: bean factories, conditional beans, configuration properties,... and you will learn how to make the most out of it.
8. Creating a configuration
- Bean Factories
- Conditional Beans
- Bean Replacement
- Bean Configuration
- Configuration Properties
- Configuration Builder
- Each Property
- Each Bean
- More options
9. Bean Factories
public class FooLibrary {
// Do stuff
}
@Singleton
public class FooLibrary {
// Do stuff
}
@Factory
public class FooFactory {
@Bean
public FooLibrary createFoo() {
return new FooLibrary();
}
}
10. Conditional Beans
@Requires(beans = DataSource.class)
@Requires(property = "datasource.url")
@Singleton
public class JdbcBookService implements BookService {
DataSource dataSource;
public JdbcBookService(DataSource dataSource) {
this.dataSource = dataSource;
}
}