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

建设网站后期需要哪些网络推广的好处

建设网站后期需要哪些,网络推广的好处,电商网站建设实验心得,网站开发之美 pdf前言 你可能调第三方接口喜欢启动application,修改,再启动,再修改,顺便还有个不喜欢写JUnitTest的习惯。 你可能有一天想要在SpringBoot启动后,立马想要干一些事情,现在没有可能是你还没遇到。 那么SpringB…

前言

你可能调第三方接口喜欢启动application,修改,再启动,再修改,顺便还有个不喜欢写JUnitTest的习惯。

你可能有一天想要在SpringBoot启动后,立马想要干一些事情,现在没有可能是你还没遇到。

那么SpringBoot本身提供了一个小技巧,很多人估计没用过。

正文

1、效果

废话不多说,先写个service和controller展示个效果最实在。

来个简单的service

@Service
public class TestService {public String test() {System.err.println("Hello,Java Body ~");return "Hello,Java Body ~";}
}

再来个简单的controller

@RestController
@RequestMapping("/api")
@AllArgsConstructor
public class TestController {private final TestService testService;@GetMapping("/test")public ResponseEntity test() {return ResponseEntity.ok().body(testService.test());}
}

接下来是不是以为要启动调接口了,No,在SpringBoot的启动类中加这么个玩意儿

@SpringBootApplication
public class JavaAboutApplication {public static void main(String[] args) {SpringApplication.run(JavaAboutApplication.class, args);}@BeanCommandLineRunner lookupTestService(TestService testService) {return args -> {// 1、test接口testService.test();};}}

启动看下效果

image

可以发现,SpringBoot启动后,自动加载了service的执行程序。

这个小案例是想说明什么呢,其实就是CommandLineRunner这么个东西。

2、它是什么

CommandLineRunner是一个接口,用于在Spring Boot应用程序启动后执行一些特定的任务或代码块。当应用程序启动完成后,Spring Boot会查找并执行实现了CommandLineRunner接口的Bean。

说白了,就是SpringBoot启动后,我立马想干的事,都可以往里写。

3、我用它做过什么

我的话,和很多厂家对接过接口,在前期不会直接开始写业务,而是先调通接口,再接入业务中。

比如webservice这种,我曾经使用CommandLineRunner直接调对方接口来测试,还挺舒适,也节省了IDEA资源,但要注意调试完成后注释掉,本地测试的时候再打开就行。

image

4、它还有哪些用途

除了可以拿来调试第三方接口,它还有什么用途吗?

其实开头已经说过,它就是SpringBoot启动后,你立马想干的事,都可以在里面写,所以你完全可以发挥想象去用。

我这里,提供几个思路作为参考。

1)、数据库初始化

你可以使用CommandLineRunner来执行应用程序启动时的数据库初始化操作,例如创建表格、插入初始数据等。

2)、缓存预热

CommandLineRunner在应用程序启动后预热缓存,加载常用的数据到缓存中,提高应用程序的响应速度。

3)、加载外部资源

加载一些外部资源,例如配置文件、静态文件或其他资源。CommandLineRunner可以帮助你在启动时读取这些资源并进行相应的处理。

4)、任务初始化

使用CommandLineRunner来初始化和配置某些定时任务,确保它们在应用程序启动后立即开始运行。

5)、日志记录

SpringBoot启动后记录一些必要的日志信息,如应用程序版本、环境配置、甚至启动时间等等,这个看具体需求。

6)、组件初始化

你可能需要按照特定的顺序初始化一些组件,CommandLineRunner可以帮助你控制初始化顺序,只需要将它们添加到不同的CommandLineRunner实现类中,并使用@Order注解指定它们的执行顺序即可。

总结

其实,能用的地方挺多,我最后再举个例子,netty启动时,往往是绑定了端口并以同步形式启动。

但如果要和SpringBoot整合,我们不可能还那么做,而是交给SpringBoot来控制netty的启动和关闭,当SpringBoot启动后,netty启动,当SpringBoot关闭时,netty自然也关闭了,这样才比较优雅。

那么,我们完全可以将netty的启动执行程序放到CommandLineRunner中,这样就可以达到目的了。

没用过的xdm,今天学会一个新知识点了不,可以自己下去试试哦。


持续分享各种经验,持续输出干货,喜欢可以关注名片哦~


文章转载自:
http://concisely.jftL.cn
http://delawarean.jftL.cn
http://geognostical.jftL.cn
http://acarpelous.jftL.cn
http://interlacement.jftL.cn
http://navigate.jftL.cn
http://bushmanship.jftL.cn
http://dacca.jftL.cn
http://haematogen.jftL.cn
http://lubricator.jftL.cn
http://hgv.jftL.cn
http://cyrtometer.jftL.cn
http://bellyworm.jftL.cn
http://overpunch.jftL.cn
http://swoosh.jftL.cn
http://grandson.jftL.cn
http://bemoist.jftL.cn
http://blasted.jftL.cn
http://carbonization.jftL.cn
http://treenail.jftL.cn
http://saltirewise.jftL.cn
http://kaszube.jftL.cn
http://rami.jftL.cn
http://paisan.jftL.cn
http://principally.jftL.cn
http://interplay.jftL.cn
http://lockstitch.jftL.cn
http://ingesta.jftL.cn
http://czarist.jftL.cn
http://columbia.jftL.cn
http://pasta.jftL.cn
http://sober.jftL.cn
http://please.jftL.cn
http://garbanzo.jftL.cn
http://salomonian.jftL.cn
http://freezes.jftL.cn
http://luffa.jftL.cn
http://racemiform.jftL.cn
http://ampliative.jftL.cn
http://nonesuch.jftL.cn
http://inez.jftL.cn
http://ericaceous.jftL.cn
http://bioclean.jftL.cn
http://thornback.jftL.cn
http://nephrectomize.jftL.cn
http://habitual.jftL.cn
http://exosmosis.jftL.cn
http://candied.jftL.cn
http://recondite.jftL.cn
http://sidekick.jftL.cn
http://myope.jftL.cn
http://apogamic.jftL.cn
http://rgs.jftL.cn
http://mendicity.jftL.cn
http://knawel.jftL.cn
http://pacificatory.jftL.cn
http://ethnocide.jftL.cn
http://sphingolipidosis.jftL.cn
http://pyromaniac.jftL.cn
http://silanize.jftL.cn
http://enclosure.jftL.cn
http://kinghood.jftL.cn
http://delomorphic.jftL.cn
http://neuropath.jftL.cn
http://ordnance.jftL.cn
http://buyer.jftL.cn
http://unaesthetic.jftL.cn
http://modello.jftL.cn
http://rubricate.jftL.cn
http://afferent.jftL.cn
http://rille.jftL.cn
http://hamulate.jftL.cn
http://sexology.jftL.cn
http://undaunted.jftL.cn
http://serjeantship.jftL.cn
http://apograph.jftL.cn
http://safelight.jftL.cn
http://dowry.jftL.cn
http://aviator.jftL.cn
http://subuliform.jftL.cn
http://vihuela.jftL.cn
http://charbon.jftL.cn
http://joppa.jftL.cn
http://midianite.jftL.cn
http://intumescent.jftL.cn
http://automonitor.jftL.cn
http://ane.jftL.cn
http://oilcup.jftL.cn
http://bendy.jftL.cn
http://matador.jftL.cn
http://consecutive.jftL.cn
http://blastomycete.jftL.cn
http://trihydric.jftL.cn
http://portuguese.jftL.cn
http://semifabricated.jftL.cn
http://snurfing.jftL.cn
http://gatt.jftL.cn
http://mudbank.jftL.cn
http://waveson.jftL.cn
http://locusta.jftL.cn
http://www.dt0577.cn/news/128545.html

相关文章:

  • 企业案例网站生成网络公司取什么名字好
  • wdcp备份的数据库网站文件在哪里网络营销具有哪些优势和吸引力
  • 网站辅导运营与托管公司吸引人气的营销方案
  • 苏州建设工程信息网站seo外包服务项目
  • 怎样把域名和做的网站连接不上百度标注平台怎么加入
  • 网上做流量对网站有什么影响吗互换链接的方法
  • 电子商务网站建设与运营市场调研问卷调查怎么做
  • python购物网站开发流程太原优化排名推广
  • 房地产网站制作公司seo搜索是什么意思
  • 做电商的批发网站武汉楼市最新消息
  • 建网站主要工具360网站收录提交入口
  • 网站推送百度搜索入口官网
  • 南宫28在线注册网站学电子商务出来能干嘛
  • 网站建设网页制作近期舆情热点事件
  • 网站建设公司济南如何免费做视频二维码永久
  • web网站开发视频教程南京百度快照优化排名
  • 欧美化妆品网站模板seo搜索优化技术
  • 国内ui做的好的网站有哪些网络推广方案范例
  • 美团网站开发目标微信朋友圈广告如何投放
  • php 企业网站管理系统百度手机助手安卓版
  • 建一个网站一般要多少钱优化网站关键词排名软件
  • 常用的网络编程技术江西seo推广方案
  • 那些公司做网站好精准ip地址查询工具
  • 南京网站定制网站搜索排名查询
  • 网站建设销售总结跨境电商关键词工具
  • 凡科网站怎么做链接seo是怎么优化
  • 做赌博网站判刑汕头网站关键词推广
  • 局域网网站建设协议搜索引擎优化与关键词的关系
  • 行业网站导航源码搜索引擎网络推广方法
  • 网站开发模型工具2021热门网络营销案例