1引入依赖
<dependency>
<groupId>com.xy</groupId>
<artifactId>xy-core-push-boot-starter</artifactId>
<version>${xy-core-push-boot-starter-version}</version>
</dependency>
2.添加配置
#是否开启消息推送
xy.core.push.enable=true
#消息推送渠道 企业微信 dingding lark
xy.core.push.channel=lark
#告警信息发送
xy.core.push.alarm-url=https://open.larksuite.com/open-apis/bot/v2/hook/d4b9d36b-288b-4d2e-8a06-bd368d7673d7
#业务逻辑通知
xy.core.push.logic-url=https://open.larksuite.com/open-apis/bot/v2/hook/d4b9d36b-288b-4d2e-8a06-bd368d7673d7
3.代码编写
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class XxxService{
private final MessageComponent messageComponent;
public void sendAlarmMessage(String message){
messageComponent.send(MessageType.Alarm_Message, XyEnvironmentUtils.getApplicationName() + ":" + message);
}
}
4.效果