当一个Application运行时,发送的事件:

当一个Application运行时,会发送如下事件:

  1. ApplicationStartingEvent
    运行run在注册完监听器与初始化器后,处理其他前触发。(测试的时候发现监听不到这个事件,暂时还不知道原因)
  2. ApplicationEnvironmentPreparedEvent
    当Environment已经准备好,在context 创建前。
  3. ApplicationContextInitializedEvent
    在ApplicationContext 创建和ApplicationContextInitializer都被调用后,但是bean definition没有被加载前。
  4. ApplicationPreparedEvent
    bean definition已经加载,但是没有refresh。
  5. ApplicationStartedEvent
    context 已经被refresh, 但是application 和command-line 的runner都没有被调用。
  6. AvailabilityChangeEvent
    带上LivenessState.CORRECT标志,标识应用是活的。
  7. ApplicationReadyEvent
    application 和command-line 的runner都被调用后。
  8. AvailabilityChangeEvent
    带上ReadinessState.ACCEPTING_TRAFFIC标志,标识应用可以提供服务。
  9. ApplicationFailedEvent
    启动过程中,抛异常了。

另外还在如下事件在ApplicationPreparedEvent 之后和ApplicationStartedEvent之前发送

  1. WebServerInitializedEvent
    WebServer已经准备好
    1.1 ServletWebServerInitializedEvent
    servlet 准备好
    1.2 ReactiveWebServerInitializedEvent
    reactive 准备好
  2. ContextRefreshedEvent
    ApplicationContext已经refresh。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一个简单的JAVA版本的短信发送接口,您可以参考以下代码: ```java import java.net.HttpURLConnection; import java.net.URL; import java.util.Scanner; public class SMS { public static void main(String[] args) { String apiKey = "your_api_key_here"; String apiSecret = "your_api_secret_here"; String from = "your_registered_number_here"; String to = "recipient_number_here"; String message = "Hello, world!"; try { URL url = new URL("https://api.smsapi.com/sms.do"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); String postData = "action=send-sms&api_key=" + apiKey + "&api_secret=" + apiSecret + "&from=" + from + "&to=" + to + "&message=" + message; byte[] postDataBytes = postData.getBytes("UTF-8"); conn.getOutputStream().write(postDataBytes); Scanner scanner = new Scanner(conn.getInputStream()); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); System.out.println(sb.toString()); } catch (Exception e) { e.printStackTrace(); } } } ``` 以上代码使用了SMSAPI.com网站的API来发送短信。您需要自行注册该网站并获取一个API密钥和API密钥以及一个已注册的手机号码。请将您的API密钥,API密钥,发送方号码,接收方号码和消息内容替换为代码中的相应值,然后运行该代码即可发送短信。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值