How do you perform CRUD operations with Azure Cosmos DB in Spring Boot?
Configure Spring Data Cosmos in Spring Boot 3, map an entity with a partition key, and run create, read, update and delete with CosmosRepository or CosmosTemplate.
2,882 posts about Java: questions with answers, tutorials and articles, newest first.
Configure Spring Data Cosmos in Spring Boot 3, map an entity with a partition key, and run create, read, update and delete with CosmosRepository or CosmosTemplate.
Use Spring application events as the Observer pattern: publish records with ApplicationEventPublisher and react with @EventListener, async or after commit.
CosmosTemplate gives Spring Boot direct access to Azure Cosmos DB containers. Learn when to use it over repositories, with working examples.
Spring publishes lifecycle events itself and lets you publish your own through ApplicationEventPublisher. See the built-in events and how to control delivery.
ApplicationListener is the Spring interface for receiving events. Learn how to implement it, compare it with @EventListener, and control ordering and threading.
Use the Spring Cloud Azure Cosmos starter and Spring Data Cosmos to map entities, choose a partition key, configure access and run CRUD from Spring Boot.
@Scope controls bean lifetime in Spring. Compare singleton, prototype and web scopes, and learn how to inject short-lived beans into singletons correctly.
There is no AzureKeyVaultTemplate in Spring Cloud Azure. Use the Key Vault secrets starter, the property source and SecretClient with a managed identity.
Load Azure Key Vault secrets into Spring Boot with the Spring Cloud Azure starter and managed identity, or read them through SecretClient.
Validate Microsoft Entra ID tokens from many tenants in Spring Boot, check issuer, tid and audience, and scope data per tenant.
Connect Spring Boot to Azure Event Hubs with Spring Cloud Azure: configure a consumer and producer, checkpoint to Storage, scale by partitions and authenticate safely.
Secure a Spring Boot app with Microsoft Entra ID (Azure AD): register the app, configure the OIDC issuer, and protect web pages or REST APIs.
Use @Scope prototype to get a new bean per request, and learn how to avoid the singleton-injects-prototype trap with ObjectProvider.
@Value injects configuration values and SpEL results into Spring beans. Learn placeholders, defaults, lists and when @ConfigurationProperties is the better choice.
Setter injection lets Spring call annotated setter methods after creating a bean. See how to use it, handle optional beans and choose it over constructor injection.
Constructor injection passes required dependencies when Spring creates a bean. See annotation, Java config and XML examples plus testing tips.
All three register Spring beans through component scanning. They differ in the layer they describe, and @Repository adds persistence exception translation.
Register Spring beans with @Configuration and @Bean methods, wire dependencies, choose scopes and lifecycle callbacks, and resolve ambiguity with @Primary and @Qualifier.
ApplicationContext is the central Spring container that wires beans, handles lifecycle, events, profiles and messages. Learn its implementations, lifecycle and best practices.
Spring instantiates, injects, initializes and destroys beans in a fixed order. Learn the lifecycle callbacks, their order, and how scopes change destruction.