springcloud14---zuul

package com.itmuch.cloud.study; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication
@EnableEurekaClient
public class FileUploadApplication {
public static void main(String[] args) {
SpringApplication.run(FileUploadApplication.class, args);
}
}
package com.itmuch.cloud.study.controller; import java.io.File;
import java.io.IOException; import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; @Controller
public class FileUploadController {
/**
有界面的测试:http://localhost:8050/index.html
使用cmd命令:curl -F "file=@文件全名" localhost:8050/upload
@return 文件在服务器上的绝对路径
*/ //把zuul启动起来(8040端口),通过http://localhost:8040/microservice-file-upload/upload访问
//也可以通过http://localhost:8040/zuul/microservice-file-upload/upload
//zuul上传小文件不加/zuul前缀,大文件加/zuul绕过spring的。
/*
zuul上传大文件要在zuul工程的配置文件设置超时:
#经过zuul的请求都会通过hysitrcs包裹,所以zuul会有断路器功能,配置hysitrcs的超时时间
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
#zuul还使用了ribbon做负载均衡,要设备ribbon的超时时间
ribbon:
ConnectTimeout: 3000
ReadTimeout: 60000
*/
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public @ResponseBody String handleFileUpload(@RequestParam(value = "file", required = true) MultipartFile file) throws IOException {
byte[] bytes = file.getBytes();
File fileToSave = new File(file.getOriginalFilename());
FileCopyUtils.copy(bytes, fileToSave);
return fileToSave.getAbsolutePath();
}
}
server:
port: 8050
#加入到eureka
eureka:
client:
serviceUrl:
defaultZone: http://user:password123@localhost:8761/eureka/
instance:
prefer-ip-address: true
spring:
application:
name: microservice-file-upload
http:
multipart:
max-file-size: 2000Mb # Max file size,默认1M
max-request-size: 2500Mb # Max request size,默认10M
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.itmuch.cloud</groupId>
<artifactId>microservice-file-upload</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <!-- 引入spring boot的依赖 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies> <!-- 引入spring cloud的依赖 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <!-- 添加spring-boot的maven插件 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
springcloud14---zuul的更多相关文章
- Netflix Zuul 了解
Zuul 是提供动态路由,监控,弹性,安全等的边缘服务.Zuul 相当于是设备和 Netflix 流应用的 Web 网站后端所有请求的前门.Zuul 可以适当的对多个 Amazon Auto Scal ...
- netflix zuul 学习
netflix zuul 是netflix开发的一个EDGE SERVICE. 主要是作为一个API Gateway 服务器,可以实现安全,流量控制等功能. 我看的是1.x的版本,Zuul1.x的实现 ...
- SpringCloud网关ZUUL集成consul
最近一直在搞基于springcloud的微服务开发,为了不限定微服务开发语言,服务发现决定采用consul不多说上代码 pom文件 <project xmlns="http://mav ...
- springcloud(十):服务网关zuul
前面的文章我们介绍了,Eureka用于服务的注册于发现,Feign支持服务的调用以及均衡负载,Hystrix处理服务的熔断防止故障扩散,Spring Cloud Config服务集群配置中心,似乎一个 ...
- Spring REST 与 Zuul 代理
http://www.baeldung.com/spring-rest-with-zuul-proxy 作者: Eugen Paraschiv 译者: http://oopsguy.com 1.概述 ...
- Zuul(SpringCloud学习笔记一)
路由是微服务架构中必须(integral )的一部分,比如,"/" 可能映射到你的WEB程序上,"/api/users "可能映射到你的用户服务上," ...
- zuul超时的解决方案
参考http://www.coolxuewang.com/view/10 在zuul的配置文件里增加如下配置: ribbon: ConnectTimeout: 6000 ReadTimeo ...
- Spring Cloud Zuul
新建Spring Boot工程,命名为zuul 1.pom.xml添加依赖 <?xml version="1.0" encoding="UTF-8"?&g ...
- Spring Cloud Zuul 添加 ZuulFilter
紧接着上篇随笔Spring Cloud Zuul写,添加过滤器,进行权限验证 1.添加过滤器 package com.dzpykj.filter; import java.io.IOException ...
- springCloud zuul网关服务
第一步:编写application.properties文件 spring.application.name=api-gateway server.port=5555 zuul.routes.user ...
随机推荐
- LNMP redis 安装、PHPredis扩展配置、服务器自启动、redis认证密码
背景: LNMP 环境(centos7) 一. 安装redis 1.下载,解压,编译 $ cd /usr/local$ wget http://download.redis.io/releases/r ...
- CSS写表格
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content_Type" content ...
- nginx代理学习
一.windows下nginx代理ftp服务器 我所在的开发环境里,nginx和ftp在同一台服务器. ftp根目录: nginx的配置: 在nginx.conf中加入: server { liste ...
- DNS隧道通信的检测
DNS隧道通信的检测 DNS 隧道通信 DNS 隧道通信是C&C常用的通信方式,一般常用的编码方式Base64,Binary编码,NetBios编码等,Hex编码等.且请求的Type一般都是t ...
- shell 中的()【】{}(())
本文转自:https://blog.csdn.net/taiyang1987912/article/details/39551385 shell中各种括号的作用().(()).[].[[]].{} 一 ...
- 代码片段,使用TIKA来解析PDF,WORD和EMAIL
/** * com.jiaoyiping.pdstest.TestTika.java * Copyright (c) 2009 Hewlett-Packard Development Company, ...
- ios开发 点击文本(TextField)输入的时候向上推以及输入之后恢复的动画
1.添加委托UITextFieldDelegate 2. -(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resi ...
- MUI事件管理
模块:事件管理 http://dev.dcloud.net.cn/mui/event/ 事件绑定: 除了可以使用addEventListener()方法监听某个特定元素上的事件外, 也可以使用.on( ...
- jquery收集表单数组及去掉字符串最后的逗号!
jquery收集表单数组: <input type='text' name='one[]' value='' /><br> <input type='text' name ...
- opencv学习笔记——FileStorage类的数据存取操作
OpenCV的许多应用都需要使用数据的存储于读取,例如经过3D校准后的相机,需要存储校准结果矩阵,以方便下次调用该数据:基于机器学习的应用,同样需要将学习得到的参数保存等.OpenCV通过XML/YA ...