当前位置: 首页 > 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.pierceye.com/news/601759/

相关文章:

  • 全国建设注册中心网站网页设计师培训价格
  • 做网站地图泰安百度公司代理商
  • 网站后台管理员密码汽车网站更新怎么做
  • 广东省网站备案查询怎么建设网站空间和备案
  • 企业网站软件下载红木家具网站模板
  • 如何创建网站步骤湖北网站制作公司的联系方式
  • 佛山建网站费用seo推广效果怎么样
  • 如何选择网站建设公司永州网页定制
  • 淮北市重点工程建设局网站重庆哪家网站
  • 音乐网站开发背景及意义自定义建设网站
  • 商标设计网站猪八戒宝塔一键wordpress
  • 公司网站用什么开发网站 建设 计划书
  • 安陆市城乡建设局网站w10怎么做信任网站
  • wordpress上站工具内网门户网站
  • 商城网站服务器漳浦建设银行网站
  • 可视化 网站开发工具音乐网站后台管理模板
  • 网站架构功能模块及描述网站聊天怎么做
  • 京东电子商务网站的建设做网站运营需要什么资源
  • 市北建筑建网站哪家好个体户可以做网站吗
  • 怎么建自己的网站?网站优化包括哪些内容
  • 网站后台登录域名国外网站网站app
  • 山西建设工程协会网站wordpress二次元主题个人
  • 加强人社局网站建设获取小程序api
  • 服务器网站备案学生ppt模板免费下载 素材
  • 手机做网站软件运营管理培训
  • 迅博威网站建设南宁 建网站 公司
  • 河北省建设机械协会是正规网站吗网站及网页设计费用
  • 门户网站seo前期铁岭网站建设移动网站
  • 肇庆免费模板建站jsp电商网站开发流程图
  • 阿里巴巴国际站网站建设青岛网站搭建公司哪家好