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

网站的策划分析网站建设与管理读书心得

网站的策划分析,网站建设与管理读书心得,网站开发专业定制,网站开发总结文档众所周知#xff0c;我不是Spring的最大粉丝#xff0c;但是当时我在一个组织中工作#xff0c;该组织使用Spring#xff08;以不同的形式和版本#xff09;维护了太多的项目。 我仍然对Spring持怀疑态度#xff0c;当然有一些很好的主意#xff0c;有一些很好的#x… 众所周知我不是Spring的最大粉丝但是当时我在一个组织中工作该组织使用Spring以不同的形式和版本维护了太多的项目。 我仍然对Spring持怀疑态度当然有一些很好的主意有一些很好的太多抽象有一些非常方便的“捷径”来引导复杂的项目。 我不会在这篇文章中详细说明我不喜欢的事情。 我喜欢Spring的文档这是他们的入门指南。 写得好具体。 我正在通过SpringBoot / RestApi [ link ]阅读有关“ 异步 ”方法执行的简短指南。 这就是示例“ asynchronous” findUser方法的实现。 完整的源代码在这里 。 Async public FutureUser findUser(String user) throws InterruptedException {System.out.println(Looking up user);User results restTemplate.getForObject(https://api.github.com/users/ user, User.class);// Artificial delay of 1s for demonstration purposesThread.sleep(1000L);return new AsyncResultUser(results); } 我想知道为什么在示例中仍然存在“未来”而我们已经介绍了Java8 CompletableFuture 。 我猜想原始作者想保持与Java早期版本6/7的向后兼容性-在该版本中该构造不可用 。 似乎其他人也有同样的问题 在这里写了一个很好的例子。 在其中的一条注释中您可以看到一个提示即从4.2版及更高版本开始Spring API将与已经提供的FutureAsyncResult之上的CompletableFuture兼容。 我想“ 很好这是一个耻辱为什么不尝试甚至记录下来因为如果有人找到了这个示例他/她可能会保留当前的实现方式 ”-为什么不使用某种标准 因此我决定做一个小小的更改删除Future并用CompletableFuture替换它还注释掉对Future.isDone的调用并用非常方便的CompletableFuture.allof方法替换它。 因此我更改了“服务”方法的返回类型同时更新了调用方代码-以同步所有3个期货一旦allof完成我们就可以打印结果。 package hello;import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future;import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate;Service public class GitHubLookupService {RestTemplate restTemplate new RestTemplate();Asyncpublic CompletableFuture findUser(String user) throws InterruptedException {System.out.println(Looking up user);User results restTemplate.getForObject(https://api.github.com/users/ user, User.class);// Artificial delay of 1s for demonstration purposesThread.sleep(1000L);return CompletableFuture.completedFuture(results);}} 修改后的示例可以在此处找到。 我从Tomasz Nirkewicz找到了这个和这篇博客文章 这是CompletableFuture丰富方法列表的非常不错且实用的指南。 我最喜欢的Devoxx演讲者Jose Paumard也做了一个非常完整的演讲您可以在这里找到。 Overridepublic void run(String... args) throws Exception {// Start the clocklong start System.currentTimeMillis();// Kick of multiple, asynchronous lookupsCompletableFuture page1 gitHubLookupService.findUser(PivotalSoftware);CompletableFuture page2 gitHubLookupService.findUser(CloudFoundry);CompletableFuture page3 gitHubLookupService.findUser(Spring-Projects);// Wait until they are all done//while (!(page1.isDone() page2.isDone() page3.isDone())) {// Thread.sleep(10); //10-millisecond pause between each check//}//wait until all they are completed.CompletableFuture.allOf(page1,page2,page3).join();//I could join as well if interested.// Print results, including elapsed timeSystem.out.println(Elapsed time: (System.currentTimeMillis() - start) ms);System.out.println(page1.get());System.out.println(page2.get());System.out.println(page3.get());} 链接 https://spring.io/guides/gs/async-method/ http://geowarin.github.io/completable-futures-with-spring-async.html http://www.nurkiewicz.com/2013/05/java-8-completablefuture-in-action.html http://www.nurkiewicz.com/2013/05/java-8-definitive-guide-to.html https://github.com/javapapo/projects-from-blog/tree/master/spring-async-complfuture 翻译自: https://www.javacodegeeks.com/2016/04/spring-async-javas-8-completablefuture.html
http://www.zqtcl.cn/news/601759/

相关文章:

  • 中小企业建站平台耐克网站建设策划方案
  • wordpress 后台加入链接后_网站显示是标签_不是链接wms智能仓储管理系统
  • 网站建设需要什么硬件和软件有哪些中考网络应用服务平台
  • 为什么网站权重会掉房地产开发网站建设
  • 大连seo整站优化酷播wordpress视频插件
  • 好的网页设计网站学编程要什么学历
  • 做网站公司电话福建城乡建设网站查询
  • 郑州做网站哪个公司好做二手市场类型的网站名字
  • 网站建设与维护里面的个人简历选择网站建设公司好
  • 济南浩辰网站建设公司怎么样wordpress 3.8 问题
  • 柳州正规网站制作公司网站ww正能量
  • 网站seo优化工具网站推广策略方法
  • 企业网站建设知名wordpress 自定义php
  • 用php做的网站有哪些全能网站建设
  • 网站显示正在建设中wordpress 排行榜 页面
  • 手机管理网站网站打开速度优化
  • 做微网站需要什么做的比较好的美食网站有哪些
  • 五金商城网站建设注意wordpress虚拟空
  • 成都工程网站建设网站界面设计的优点
  • 网站建设里的知识找别人做公司网站第一步做什么
  • 婚纱摄影网站模板之家专业seo网站优化公司
  • 商丘市住房和城乡建设局网站广西网站建设timkee
  • php网站开发是做什么的网站策划总结
  • 站长工具seo推广秒收录WordPress注册插件中文
  • 目前个人网站做地最好是哪几家做汽配网站需要多少钱
  • php做网站多少钱网络营销推广方案3篇
  • 浙江坤宇建设有限公司 网站省直部门门户网站建设
  • 直播类网站怎么做上海市建设质量协会网站
  • 筑巢做网站怎么样网站设计接单
  • 会ps的如何做网站wordpress 仿虎嗅