{"id":3135,"date":"2018-09-28T17:25:01","date_gmt":"2018-09-28T09:25:01","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3135"},"modified":"2018-09-28T17:25:01","modified_gmt":"2018-09-28T09:25:01","slug":"spring-boot-webflux-%e4%bf%ae%e6%94%b9%e6%9c%80%e5%a4%a7%e4%b8%8a%e4%bc%a0%e6%96%87%e4%bb%b6%e9%99%90%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3135","title":{"rendered":"Spring Boot WebFlux \u4fee\u6539\u6700\u5927\u4e0a\u4f20\u6587\u4ef6\u9650\u5236"},"content":{"rendered":"<p>\n\t\u5728\u521a\u624d\u7684\u90a3\u7bc7\u6587\u7ae0\u4e2d\uff0c\u540e\u53f0\u6709\u4eba\u7559\u8a00\u8bf4\uff0c\u6587\u4ef6\u592a\u5927\u65e0\u6cd5\u4e0a\u4f20\u3002\u54ce\uff0c\u6211\u521a\u5199\u597d\u7684\u6587\u7ae0\uff0c\u8fd8\u6ca1\u597d\u597d\u6b23\u8d4f\u5462\uff1f\u4e8e\u662f\u5462\u5c31\u6709\u4e86\u672c\u6587\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u641e\u5b9a\u4e0a\u4f20\u6587\u4ef6\u8fc7\u5927\u95ee\u9898\u3002\n<\/p>\n<p>\n\t\u4e0a\u4f20\u6587\u4ef6\u9650\u5236\u8fd9\u4e2a\u529f\u80fd\uff0c\u5927\u90e8\u5206\u6846\u67b6\u90fd\u6709\u3002WebFlux \u8fd9\u4e2a\u6846\u67b6\u4e5f\u4e0d\u4f8b\u5916\u3002\u7531\u4e8e\u6211\u4eec\u7528\u7684\u662f SpringBoot 2.0 \u4ee5\u4e0a\u7684\u7248\u672c\uff0c\u6240\u4ee5\u50cf\u4f60\u4e4b\u524d\u4e00\u6837\u7684\u65b9\u6cd5\u6765\u914d\u7f6e\u4e0a\u4f20\u5927\u5c0f\u7684\u9650\u5236\u662f\u4e0d\u53ef\u53d6\u7684\u3002\u90a3\u8be5\u5982\u4f55\u914d\u7f6e\u5462\uff1f\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"The field file exceeds its maximum permitted size of 1048576 bytes\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/mvc-webflux.jpg\" style=\"width: 573px;height: 339px\" \/>\n<\/p>\n<p>\n\t\u8fd8\u662f\u548c\u4ee5\u524d\u4e00\u6837\uff0c\u6211\u4eec\u53bb\u627e&nbsp;autoconfigure \u5305\u3002\u56e0\u4e3a SpringBoot \u7684\u6838\u5fc3\u5c31\u662f\u81ea\u52a8\u914d\u7f6e\uff0c\u81ea\u52a8\u914d\u7f6e\u7684\u6240\u6709\u4e1c\u897f\u90fd\u5728&nbsp;autoconfigure \u4e2d\u3002\u7136\u540e\u6211\u4eec\u627e\u5230\u8fd9\u4e2a\u7c7b&nbsp;MultipartProperties.java\u3002\u5b83\u91cc\u9762\u6709\u4e0b\u9762\u7684\u8fd9\u51e0\u6bb5\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@ConfigurationProperties(\r\n    prefix = &quot;spring.servlet.multipart&quot;,\r\n    ignoreUnknownFields = false\r\n)\r\npublic class MultipartProperties {\r\n    private boolean enabled = true;\r\n    private String location;\r\n    private String maxFileSize = &quot;1MB&quot;;\r\n    private String maxRequestSize = &quot;10MB&quot;;\r\n    private String fileSizeThreshold = &quot;0&quot;;\r\n    private boolean resolveLazily = false;<\/pre>\n<p>\n\t\u9ed8\u8ba4\u7684\u6700\u5927\u6587\u4ef6\u4e0a\u4f20\u662f 1MB\u3002\u5982\u679c\u8d85\u8fc7 1M \u5462\uff0c\u5c31\u4f1a\u62a5\uff1a&ldquo;The field file exceeds its maximum permitted size of 1048576 bytes.&ldquo;\u5bfc\u81f4\u6587\u4ef6\u65e0\u6cd5\u4e0a\u4f20\u3002\n<\/p>\n<p>\n\t\u6240\u4ee5\u5462\uff0c\u6211\u4eec\u5728&nbsp;application.properties \u6587\u4ef6\u4e2d\u914d\u7f6e\u4e00\u4e0b\u5185\u5bb9\u5373\u53ef\u3002\n<\/p>\n<pre class=\"brush:plain;\">\r\nspring.servlet.multipart.enabled=true\r\nspring.servlet.multipart.max-file-size=5MB\r\nspring.servlet.multipart.max-request-size=5MB<\/pre>\n<p>\n\t\u73b0\u5728\u4f60\u4f1a\u53d1\u73b0\uff0c\u914d\u7f6e\u5c5e\u6027\u7684\u524d\u7f00\u53d8\u6210\u4e86&nbsp;spring.servlet.multipart.xx \u3002\u6240\u4ee5\u4f60\u5982\u679c\u8fd8\u5728\u6309\u7167 SpringBoot 1.x \u7684\u65b9\u5f0f\u6765\u914d\u7f6e\uff0c\u80af\u5b9a\u4e0d\u4f1a\u751f\u6548\u7684\u3002\n<\/p>\n<p>\n\t\u5728&nbsp;Spring Boot 1.3.x\u6216\u8005\u4e4b\u524d\uff0c\u914d\u7f6e\u7528\u6cd5\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\nmultipart.maxFileSize=100Mb\r\nmultipart.maxRequestSize=1000Mb<\/pre>\n<p>\n\tSpring Boot 1.4.x \u4ee5\u540e\uff0c\u53d8\u6210\u4e86\u4e0b\u9762\u7684\u914d\u7f6e\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nspring.http.multipart.maxFileSize=100Mb\r\nspring.http.multipart.maxRequestSize=1000Mb<\/pre>\n<p>\n\t\u5728 Spring Boot 2.0 \u4e4b\u540e\u5462\uff1f\u5b83\u53c8\u53d8\u4e86\u3002\u53d8\u6210\u4e86\u4e0a\u9762\u6211\u6700\u5f00\u59cb\u7684\u914d\u7f6e\u3002\n<\/p>\n<p>\n\t\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u53d1\u73b0 Spring Boot \u975e\u5e38\u7684\u5584\u53d8\uff0c\u90a3\u662f\u4e0d\u662f\u4ee5\u540e SpringBoot \u6ca1\u5347\u7ea7\u4e00\u6b21\uff0c\u90fd\u4f1a\u53d8\u5462\uff1f\n<\/p>\n<p>\n\t\u7b54\u6848\u662f\uff0c\u4e0d\u7ba1\u5b83\u53d8\u4e0e\u4e0d\u53d8\uff0c\u53ea\u8981\u6211\u4eec\u638c\u63e1\u8bc0\u7a8d\uff0c\u518d\u53d8\u6211\u4eec\u90fd\u4e0d\u6015\u3002\u6ce8\u610f\uff1a\u4e00\u5207\u81ea\u52a8\u914d\u7f6e\u90fd\u5728 autoconfigure \u5305\u4e2d\uff0c\u53ea\u9700\u8981\u627e\u5bf9\u5e94\u7684 XXXProperties \u7c7b\u5373\u53ef\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3135\">Spring Boot WebFlux \u4fee\u6539\u6700\u5927\u4e0a\u4f20\u6587\u4ef6\u9650\u5236<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5728\u521a\u624d\u7684\u90a3\u7bc7\u6587\u7ae0\u4e2d\uff0c\u540e\u53f0\u6709\u4eba\u7559\u8a00\u8bf4\uff0c\u6587\u4ef6\u592a\u5927\u65e0\u6cd5\u4e0a\u4f20\u3002\u54ce\uff0c\u6211\u521a\u5199\u597d\u7684\u6587\u7ae0\uff0c\u8fd8\u6ca1\u597d\u597d\u6b23\u8d4f\u5462\uff1f\u4e8e\u662f\u5462\u5c31\u6709\u4e86\u672c\u6587\uff0c\u6211 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[481,70,1701,177,517],"class_list":["post-3135","post","type-post","status-publish","format-standard","hentry","category-java","tag-fastdfs","tag-java","tag-webflux","tag-177","tag-517"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3135"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3135\/revisions"}],"predecessor-version":[{"id":3136,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3135\/revisions\/3136"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}