当前位置: 首页 > news >正文

网页设计与网站建设主要内容在微信怎么开发公众号

网页设计与网站建设主要内容,在微信怎么开发公众号,公司简介模板免费word简易,临城网站CommandLineRunner 和 ApplicationRunner 都是 Spring Boot 中用于在应用启动后执行特定逻辑的接口。它们的主要区别在于传递的参数类型和执行顺序。下面我将为您详细解释它们的用途、使用案例以及执行顺序。 CommandLineRunner CommandLineRunner 是一个接口#xff0c;它有…CommandLineRunner 和 ApplicationRunner 都是 Spring Boot 中用于在应用启动后执行特定逻辑的接口。它们的主要区别在于传递的参数类型和执行顺序。下面我将为您详细解释它们的用途、使用案例以及执行顺序。 CommandLineRunner CommandLineRunner 是一个接口它有一个方法 run接受一个类型为 String[] 的参数表示应用启动时传递的命令行参数。通常用于执行一些与命令行参数相关的初始化操作。 使用案例 假设您的应用需要根据命令行参数初始化一些配置您可以使用 CommandLineRunner 来实现 import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.stereotype.Component;SpringBootApplication public class MyApplication {public static void main(String[] args) {SpringApplication.run(MyApplication.class, args);} }Component class MyCommandLineRunner implements CommandLineRunner {Overridepublic void run(String... args) throws Exception {// 根据命令行参数执行初始化操作if (args.length 0 args[0].equals(init)) {System.out.println(执行初始化操作);}} }在这个例子中如果您在启动应用时传递了命令行参数 “init”MyCommandLineRunner 的 run 方法将会执行相应的初始化操作。 ApplicationRunner ApplicationRunner 是一个接口也有一个方法 run接受一个类型为 ApplicationArguments 的参数主要目的是在应用程序上下文加载之后运行一些代码。 使用案例 假设您的应用需要在应用程序上下文加载之后运行一些代码您可以使用 ApplicationRunner import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.stereotype.Component;SpringBootApplication public class MyApplication {public static void main(String[] args) {SpringApplication.run(MyApplication.class, args);} }Component class MyApplicationRunner implements ApplicationRunner {Overridepublic void run(ApplicationArguments args) throws Exception {// 执行初始化操作} }执行顺序的定义 在 Spring Boot 中CommandLineRunner 和 ApplicationRunner 的执行顺序是通过 Order 注解或 Ordered 接口来定义的。通过这些方式您可以明确指定执行的顺序或者让 Spring Boot 自动根据数字值进行排序。 以下是一个示例展示了如何使用 Order 注解来定义执行顺序 import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component;SpringBootApplication public class MyApplication {public static void main(String[] args) {SpringApplication.run(MyApplication.class, args);} }Component Order(2) class MyCommandLineRunner1 implements CommandLineRunner {Overridepublic void run(String... args) throws Exception {System.out.println(MyCommandLineRunner1 执行);} }Component Order(1) class MyCommandLineRunner2 implements CommandLineRunner {Overridepublic void run(String... args) throws Exception {System.out.println(MyCommandLineRunner2 执行);} }在这个示例中MyCommandLineRunner2 的 run 方法会在 MyCommandLineRunner1 的 run 方法之前执行因为它们分别使用了不同的 Order 值。 总之CommandLineRunner 和 ApplicationRunner 接口都是用于在 Spring Boot 应用启动后执行特定逻辑的强大工具。您可以根据需要使用它们来执行初始化操作、业务逻辑或其他自定义操作并通过 Order 或 Ordered 接口来控制它们的执行顺序。
http://www.hkea.cn/news/14394287/

相关文章:

  • 网站建设工作的作用自己做网站需要服务器吗
  • 网站建设论坛机械手表网站
  • 网站开发最新技术能看网站的浏览器
  • 三水顺德网站建设做网站图片如何压缩图片
  • 装饰公司网站模版用什么程序做视频网站
  • 做网站坂田手机自己免费制作app软件
  • 网站建设的意义怎么写莆田网站 建设
  • 自己网站建设的流程是什么开发公司的一般利润率2020
  • 做网站需要办什么证件wordpress链接样式设置方法
  • 阿里云中英文网站建设上市公司专利查询网站
  • 服装网站设计模板化妆品网站设计论文
  • django企业网站开发实例导航网站怎么做点击
  • 电子商务网站有哪些和网址广州哪里有网站建设
  • 网站seo优化课程个人手机版网站建设
  • 网站域名批量查询注册双井网站建设
  • asp.net做报名网站如何给异地网站做镜像
  • 电子商务网站建设合同seo招聘的关键词
  • wordpress 新闻采集站网站建设 猴王网络0成本
  • 网站ui设计包括哪些原则苏州高端网站定制
  • dede做的网站打不开wordpress淘宝采集
  • 网站建设需要什么软件有哪些东宁做木耳招工人网站
  • 网站修改dns线上免费编程课
  • 承装承修承试材料在哪个网站做制作一个网站费用
  • 网站百度收录是什么意思wordpress远程插件
  • 新建的网站可以百度推广seo是指什么岗位
  • 青岛做门户网站的建设网站需要几个文件夹
  • 深圳公明网站建设本周新闻热点10条2021
  • 海外仓网站建设大良手机网站建设
  • 备案 网站名称涉及到行业网站页面大小优化怎么做
  • 艺术设计专业灵感推荐网站品牌网站建设4a小蝌蚪