<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Spring on 村边的池塘</title>
		<link>https://jerrywang1981.github.io/categories/spring/</link>
		<description>Recent content in Spring on 村边的池塘</description>
		<generator>Hugo</generator>
		<language>zh-CN</language>
		
		
		
		
			<lastBuildDate>Fri, 11 Sep 2020 15:55:30 +0800</lastBuildDate>
		
			<atom:link href="https://jerrywang1981.github.io/categories/spring/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>添加第三方jar到Spring Boot application</title>
				<link>https://jerrywang1981.github.io/post/java/add-third-party-jar-to-spring-boot/</link>
				<pubDate>Fri, 11 Sep 2020 15:55:30 +0800</pubDate>
				<guid>https://jerrywang1981.github.io/post/java/add-third-party-jar-to-spring-boot/</guid>
				<description>&lt;h2 id=&#34;背景&#34;&gt;背景&lt;/h2&gt;&#xA;&lt;p&gt;有时候需要添加第三方的jar包到spring boot工程中，因为不能从maven repository直接下载，所以需要包含在代码库中。&#xA;一般需要在&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;src/main&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;目录下，可以建个新目录 &lt;code&gt;lib&lt;/code&gt;, 然后把jar文件放到这个目录下，也就是 src/main/lib下.&lt;/p&gt;&#xA;&lt;p&gt;然后在pom.xml中需要添加&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;groupId/artifactId/version/scope都需要填上&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;        &amp;lt;dependency&amp;gt;&#xA;            &amp;lt;groupId&amp;gt;com.ibm.bluepages&amp;lt;/groupId&amp;gt;&#xA;            &amp;lt;artifactId&amp;gt;bpjtk&amp;lt;/artifactId&amp;gt;&#xA;            &amp;lt;version&amp;gt;3.0.6.0&amp;lt;/version&amp;gt;&#xA;            &amp;lt;scope&amp;gt;system&amp;lt;/scope&amp;gt;&#xA;            &amp;lt;systemPath&amp;gt;${project.basedir}/src/main/lib/bpjtk-v3.0.6.0.jar&amp;lt;/systemPath&amp;gt;&#xA;        &amp;lt;/dependency&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&#xA;&lt;li&gt;在 spring-boot-maven-plugin中加上 includeSystemScope true&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;        &amp;lt;plugins&amp;gt;&#xA;            &amp;lt;plugin&amp;gt;&#xA;                &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&#xA;                &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;&#xA;                &amp;lt;configuration&amp;gt;&#xA;                  &amp;lt;includeSystemScope&amp;gt;true&amp;lt;/includeSystemScope&amp;gt;&#xA;                &amp;lt;/configuration&amp;gt;&#xA;            &amp;lt;/plugin&amp;gt;&#xA;        &amp;lt;/plugins&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
			</item>
			<item>
				<title>Vue File Download From Spring Boot</title>
				<link>https://jerrywang1981.github.io/post/vue/file-download-from-spring-boot/</link>
				<pubDate>Thu, 10 Sep 2020 07:52:49 +0800</pubDate>
				<guid>https://jerrywang1981.github.io/post/vue/file-download-from-spring-boot/</guid>
				<description>&lt;h2 id=&#34;file-download&#34;&gt;File download&lt;/h2&gt;&#xA;&lt;p&gt;如果spring boot的写法是我在另外一个&lt;a href=&#34;../java/spring-boot-file-download.md&#34;&gt;文章&lt;/a&gt;, 返回的response其实是一个Blob,&#xA;这一点要记住&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;          this.axios.get(url, { responseType: &amp;#39;blob&amp;#39;, timeout: 0 }).then(response =&amp;gt; {&#xA;              // response is Blob &amp;lt;-------&#xA;                const url = window.URL.createObjectURL(response)&#xA;                const a = document.createElement(&amp;#39;a&amp;#39;)&#xA;                a.style.display = &amp;#39;none&amp;#39;&#xA;                a.href = url&#xA;                a.setAttribute(&amp;#39;download&amp;#39;,&amp;#39;file.xlsx&amp;#39;)&#xA;                document.body.appendChild(a)&#xA;                a.click()&#xA;                document.body.removeChild(a);&#xA;                window.URL.revokeObjectURL(url);&#xA;          });&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
			</item>
			<item>
				<title>Spring Boot File Download</title>
				<link>https://jerrywang1981.github.io/post/java/spring-boot-file-download/</link>
				<pubDate>Thu, 10 Sep 2020 07:52:13 +0800</pubDate>
				<guid>https://jerrywang1981.github.io/post/java/spring-boot-file-download/</guid>
				<description>&lt;h2 id=&#34;spring-boot-application&#34;&gt;spring boot application&lt;/h2&gt;&#xA;&lt;p&gt;提供下载的代码，可以返回一个Resource&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;@RestController&#xA;@RequiredArgsConstructor&#xA;@RequestMapping(&amp;#34;/api&amp;#34;)&#xA;public class ReportController {&#xA;&#xA;&#xA;&#xA;    @GetMapping(value = &amp;#34;/filedownload&amp;#34;)&#xA;    public ResponseEntity&amp;lt;InputStreamResource&amp;gt; downloadFile(HttpServletRequest request) {&#xA;&#xA;        // .......................&#xA;        // .......................&#xA;        // .......................&#xA;&#xA;        ByteArrayInputStream stream = xxxxxx;// get the stream&#xA;&#xA;        return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM)&#xA;                .header(HttpHeaders.CONTENT_DISPOSITION, &amp;#34;attachment; filename=file.xlsx&amp;#34;)&#xA;                .body(new InputStreamResource(stream));&#xA;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
			</item>
	</channel>
</rss>
