spring-notify is on Maven Central — just add the dependencies.
Import the BOM once so every notify-* module resolves to the same version and you can omit
<version> on the individual artifacts:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>sk.solodev</groupId>
<artifactId>notify-bom</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>Pick the backend you want. The starter pulls in the channel and the whole pipeline transitively:
<dependency>
<groupId>sk.solodev</groupId>
<artifactId>notify-spring-boot-starter-sms-twilio</artifactId>
</dependency>spring:
notify:
sms:
twilio:
account-sid: ${TWILIO_ACCOUNT_SID}
auth-token: ${TWILIO_AUTH_TOKEN}Config keys autocomplete in your IDE — every provider's keys ship with generated metadata.
@Service
class OrderService {
private final Notifier notifier;
OrderService(Notifier notifier) {
this.notifier = notifier;
}
void onShipped(Order order) {
String messageId = notifier.notify(SmsRequest.builder()
.to(order.phone())
.from("+421900999888")
.message("Your order has shipped")
.build());
}
}notify(...) returns the provider message id, or throws NotificationDeliveryException (carrying
the failed request) on failure. To send off the calling thread, use notifyAsync(...) — see
Concepts.
Next: Concepts — understand the pipeline. Or jump to Providers for backend configuration, or Testing to assert sends without a real provider.