uri

SpringCloud(五) 使用Ribbon进行Restful请求

余生颓废 提交于 2020-02-02 08:56:18
写在前面 本文由markdown格式写成,为本人第一次这么写,排版可能会有点乱,还望各位海涵。 主要写的是使用Ribbon进行Restful请求,测试各个方法的使用,代码冗余较高,比较适合初学者,介意轻喷谢谢。 前提 一个可用的Eureka注册中心(文中以之前博客中双节点注册中心,不重要) 一个连接到这个注册中心的服务提供者 一个ribbon的消费者 注意:文中使用 @GetMapping 、 @PostMapping 、 @PutMapping 、 @DeleteMapping 等注解需要升级 spring-boot-starter-parent版本到1.5.9.REALEASE以上(1.3.7.RELEASE版本没有这些注解) 建议:每个微服务应用都有自己的 spring-boot-maven-plugin 和 maven-compiler-plugin 并指定jdk编译版本为1.8 ,指定方式如下,pom.xml中添加 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins<

spring boot单元测试之RestTemplate(三)——api详解

被刻印的时光 ゝ 提交于 2020-02-02 08:14:31
本篇内容来自翟永超的《Springcloud微服务实战》,转载请注明。 一、GET请求 在RestTemplate中,对GET请求可以通过如下两个方法进行调用实现。 第一种:getForEntity函数。 该方法返回的是ResponseEntity,该对象是Spring对HTTP请求响应的封装,其中主要存储了HTTP的几个重要元素,比如HTTP请求状态码的枚举对象HttpStatus(也就是我们常说的404、500这些错误码)、在它的父类HttpEntity中还存储着HTTP请求的头信息对象HttpHeaders以及泛型类型的请求体对象。 比如下面的例子,就是访问USER-SERVER服务的/user请求,同时最后一个参数didi会替换url中的{1}占位符,而返回的ResponseEntity对象中的body内容类型会根据第二个参数转换为String类型。 RestTemplaterestTemplate=newRestTemplate(); ResponseEntity<String>responseEntity=restTemplate.getForEntity("http://USERSERVICE/user?name={1}",String.class,"didi"); Stringbody=responseEntity.getBody();

Structured Data > Microdata & Json-LD > Entity IDs > Fragment Identifier

和自甴很熟 提交于 2020-02-02 04:51:12
问题 I was wondering if it is better/proper to reference the entities using a fragment identifier format - basically by inserting a hash before the name [url] + # + [name] => http://example.com/page/#webPage EDIT: Following a kind answer from the ever-generous and great @Unor, I have added this edit to try confine the scope of my query and clarify the main issue I am getting at. I have also deleted most of the original question (about 95%) which (in hindsight) I feel detracts from: 1. my core

Android Programming - Making a URI to get audio location

会有一股神秘感。 提交于 2020-02-01 03:16:47
问题 I'm brand new to Java and also android programming, so things are a little strange to me! I mainly come from a background in C++/C# so speak the tech! Anyhow. I'm trying to create a simple class that handles audio for a custom music player i'm designing. I've got all the keypress events handled, so now i'm working on the functionality. I'm using the MediaPlayer class for handling most of the hard stuff, but I'm a little confused on how to access audio that is saved on a users mobile device. I

ListView Display and File to Uri

为君一笑 提交于 2020-02-01 00:25:56
How can adapter display the content of the listview. 1.AbsListView.java [cpp] view plain copy protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec) { ....... final View child = obtainView(0, mIsScrap); ..... } //one item, called one time. 2.AbsListView.java [java] view plain copy View obtainView( int position, boolean [] isScrap) { .... child = mAdapter.getView(position, scrapView, this ); .... } 3.CursorAdapter.java [java] view plain copy public View getView( int position, View convertView, ViewGroup parent) { ..... if (convertView == null ) { v = newView(mContext, mCursor,

Is a (local) file path an URI?

风流意气都作罢 提交于 2020-01-31 13:34:26
问题 On some input we allow the following paths: C:\Folder \\server\Folder http://example.com/... I wonder if I can mark them all as "URI"s? Thanks! 回答1: C:/Folder and /server/Folder/ are file paths. http://example.com/ is a URL, which is a URI sub-type, so you could mark it as a URI but not the other way around (like how squares are rectangles but not vice versa). Of course, here you have posted a clear, simple example. When discussing the distinction between URI and URL, not only is the answer

How to check if resource pointed by Uri is available?

╄→尐↘猪︶ㄣ 提交于 2020-01-31 04:23:50
问题 I have resource (music file) pointed by Uri. How can I check if it is available before I try to play it with MediaPlayer? Its Uri is stored in database, so when the file is deleted or on external storage that is unmounted, then I just get exception when I call MediaPlayer.prepare(). In above situation I would like to play systems default ringtone. I could of course do that after I catch above exception, but maybe there is some more elegant solution? edit: I forgot to mention that music files

入门Nginx

一笑奈何 提交于 2020-01-31 02:05:05
一、正向代理和反向代理 正向代理举例:翻越万里长城去游览墙外的景色 反向代理举例:负载均衡 正向代理和反向代理涉及三个主体: 请求方 代理 被请求方 正向代理中,代理跟请求方是一家子,请求方说要啥,代理就给他啥。 反向代理中,代理跟被请求方是一家子,代理统筹规划让哪一个被请求方来处理请求,对于请求方来说,代理就是处理请求的人。大多数情况下,反向代理和被请求方在同一个服务器上。Nginx就是最常用的反向代理服务器。 这里也提一下:动态代理和静态代理 正向代理和反向代理是代理服务器的两种类型 动态代理和静态代理是Java中的设计模式:代理模式。 Spring的两大核心: IOC控制反转依赖注入 AOP面向切面编程 面向切面编程中大量使用动态代理,在每一个方法调用前、调用后、抛异常时进行处理,跟装饰器模式很像。 二、nginx配置体系 nginx主要配置位于/etc/nginx目录下,nginx不仅仅可以用于负载均衡HTTP请求,也可以用于基于TCP的其它协议的负载均衡。/etc/nginx/nginx.conf是nginx的跟配置,一切配置都是这个配置的子孙。 /etc/nginx/nginx.conf users www-data;定义当前用户 worker_prosesses 4;定义worker数 pid /run/nginx.pid;定义pid文件 events{......}

Android Intent用法总结

时光总嘲笑我的痴心妄想 提交于 2020-01-31 00:46:05
Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用。Intent不仅可用于应用程序之间,也可用于应用程序内部的 Activity / Service之间的交互。因此,Intent在这里起着一个媒体中介的作用,专门提供组件互相调用的相关信息,实现调用者与被调用者之间的解耦。 1. Intent作用 Intent是一个将要执行的动作的抽象的描述,一般来说是作为参数来使用,由 Intent来协助完成 Android各个组件之间的通讯。比如说调用startActivity()来启动一个Activity,或者由broadcaseIntent()来传递给所有感兴趣的BroadcaseReceiver,再或者由startService() / bindservice()来启动一个后台的 service。所以可以看出来,Intent 主要是用来启动其他的 activity 或者 service,所以可以将 intent 理解成 activity 之间的粘合剂。 Intent作用的表现形式为: 启动Activity 通过Context.startActvity() / Activity

Apache Synapse

大城市里の小女人 提交于 2020-01-30 00:41:06
Apache Synapse可以提供企业服务总线(ESB,Enterprise Service Bus)的许多功能。可以从很多厂商那里获得ESB,通过可扩展标记语言(EXML,Extensible Markup Language)Web服务接口以及基于规则的标准化路由,在企业系统之间提供安全的互用性。 ESB有这么一个功能,把XML文件从一种数据格式转换为另一种,从而使得可以在不同的应用程序中共享这些文件。此外,ESB还保证可以在预设规则的基础上共享数据。 下载: http://synapse.apache.org/download.html Apache Synapse 特性 1、基于 Apache Axis2, 最新 1.2 版本 2 、支持服务注册以及寻址管理 3 、支持 WS-Addressing/WS-Security/WS-RM 等规范 4 、支持 HTTP(S)/JMS/POP3/SMTP/IMAP/FIX 等协议以及转换 5 、消息处理:消息接收、转发、中介、路由、错误处理 6 、服务质量 7 、支持 Load Balance 和 Failover, 以及服务缓存 8 、支持脚本中介,无需修改应用代码,通过 JS 等脚本来控制消息 9 、 JMX, 支持自治监控 消息仲裁框架 Apache Synapse 实现了通用的中介框架。可以指定一个对消息进行操作