<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Springboot on Margrop Blog</title>
    <link>https://blog.margrop.net/en/tag/springboot/</link>
    <description>Recent content in Springboot on Margrop Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Sun, 12 Mar 2023 20:20:01 +0800</lastBuildDate>
    <atom:link href="https://blog.margrop.net/en/tag/springboot/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Fixing CORS Issues When Upgrading from Spring 2.3.x to a Newer Version</title>
      <link>https://blog.margrop.net/en/post/fix-spring2-allowed-origins-error/</link>
      <pubDate>Sun, 12 Mar 2023 20:20:01 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/fix-spring2-allowed-origins-error/</guid>
      <description>&lt;h1 id=&#34;exception-message&#34;&gt;Exception Message:&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;When allowCredentials is true, allowedOrigins cannot contain the special value &amp;#34;*&amp;#34; since that cannot be set on the &amp;#34;Access-Control-Allow-Origin&amp;#34; response header. To allow credentials to a set of origins, list them explicitly or consider using &amp;#34;allowedOriginPatterns&amp;#34; instead.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;solution&#34;&gt;Solution:&lt;/h1&gt;&#xA;&lt;p&gt;CORS configuration error, simply replace &lt;code&gt;.allowedOrigins&lt;/code&gt; with &lt;code&gt;.allowedOriginPatterns&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fixing SpringFox 3.0.0 Incompatibility with SpringBoot 2.6.4</title>
      <link>https://blog.margrop.net/en/post/fix-springfox-documentation-plugins-bootstrapper-npe/</link>
      <pubDate>Sun, 12 Mar 2023 17:56:57 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/fix-springfox-documentation-plugins-bootstrapper-npe/</guid>
      <description>&lt;h1 id=&#34;error-message&#34;&gt;Error Message:&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Failed to start bean &amp;#39;documentationPluginsBootstrapper&amp;#39;; nested exception is java.lang.NullPointerException&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;root-cause-analysis&#34;&gt;Root Cause Analysis:&lt;/h1&gt;&#xA;&lt;p&gt;&lt;code&gt;SpringFox&lt;/code&gt; 3.0.0 is not compatible with &lt;code&gt;SpringBoot&lt;/code&gt; 2.6.4&lt;/p&gt;&#xA;&lt;h1 id=&#34;solution&#34;&gt;Solution:&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reference Links&#xA;&lt;a href=&#34;https://stackoverflow.com/questions/40241843/failed-to-start-bean-documentationpluginsbootstrapper-in-spring-data-rest&#34;&gt;https://stackoverflow.com/questions/40241843/failed-to-start-bean-documentationpluginsbootstrapper-in-spring-data-rest&lt;/a&gt;&#xA;&lt;a href=&#34;https://github.com/springfox/springfox/issues/3462#issuecomment-1010721223&#34;&gt;https://github.com/springfox/springfox/issues/3462#issuecomment-1010721223&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Java Spring Boot JNI Native Library Loader</title>
      <link>https://blog.margrop.net/en/post/java-spring-boot-jni-java-native-interface-library-loader/</link>
      <pubDate>Sat, 27 Mar 2021 16:37:31 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/java-spring-boot-jni-java-native-interface-library-loader/</guid>
      <description>&lt;p&gt;Because Java needs to stay cross-platform, I wrote a cross-platform JNI native library loader.&lt;/p&gt;&#xA;&lt;h1 id=&#34;simple-implementation&#34;&gt;Simple Implementation&lt;/h1&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Determine whether the current system is &lt;code&gt;Windows&lt;/code&gt;, &lt;code&gt;Linux&lt;/code&gt;, or &lt;code&gt;MacOS&lt;/code&gt; from the &lt;code&gt;os.name&lt;/code&gt; environment property.&lt;/li&gt;&#xA;&lt;li&gt;If it is &lt;code&gt;Linux&lt;/code&gt;, further determine whether it is &lt;code&gt;CentOS&lt;/code&gt; or &lt;code&gt;Debian&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Read the library files inside the jar package.&lt;/li&gt;&#xA;&lt;li&gt;Filter the matching platform library files by file suffix: &lt;code&gt;dll&lt;/code&gt;, &lt;code&gt;so&lt;/code&gt;, &lt;code&gt;jnilib&lt;/code&gt;, and &lt;code&gt;dylib&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Copy the current platform&amp;rsquo;s library file to the system temporary directory &lt;code&gt;java.io.tmpdir&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Load the library using &lt;code&gt;System.load&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;</description>
    </item>
    <item>
      <title>Spring Boot &#43; Undertow upload file cannot find temporary directory</title>
      <link>https://blog.margrop.net/en/post/spring-boot-undertow-upload-file-not-found-temp-folder/</link>
      <pubDate>Sat, 27 Mar 2021 11:17:26 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/spring-boot-undertow-upload-file-not-found-temp-folder/</guid>
      <description>The problem occurs Two days ago, the company&amp;rsquo;s SpringBoot project suddenly had a problem of being unable to upload Excel files.&#xA;After checking the Java log, I found a large number of exceptions: java.nio.file.NoSuchFileException: /tmp/undertow.12020.9432679758080410942/undertow17157208698492118168upload&#xA;Detailed exception information is as follows:&#xA;org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.RuntimeException: java.nio.file.NoSuchFileException: /tmp/undertow.12020.9432679758080410942/undertow17157208698492118168upload at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:124) at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:115) at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.&amp;lt;init&amp;gt;(StandardMultipartHttpServletRequest.java:88) at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:87) at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1199) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1033) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.</description>
    </item>
    <item>
      <title>The biggest pitfall of SpringBoot DevTools, none of them</title>
      <link>https://blog.margrop.net/en/post/springboot-devtools-terrible/</link>
      <pubDate>Wed, 03 Mar 2021 18:23:39 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/springboot-devtools-terrible/</guid>
      <description>Recently, a lot of changes have been added to the SpringBoot project, and then I encountered a very strange problem.&#xA;HibernateDatabase query error This is simply weird Expected type and actual value are exactly the same, but Hibernate thinks they are different. How can this be fixed?&#xA;After struggling with this strange problem for a day, I found that this only occurs on my local machine. The same code is completely normal on the test server.</description>
    </item>
    <item>
      <title>[Transfer] Spring AOP intercepts classes or methods with specified annotation identifiers</title>
      <link>https://blog.margrop.net/en/post/spring-aop-annotation-and-within/</link>
      <pubDate>Thu, 14 Jan 2021 15:29:41 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/spring-aop-annotation-and-within/</guid>
      <description>Instructions for scanning specific annotations in AOP: (1) @annotation: intercepts all methods annotated with the target annotation. (2) @within: intercepts all classes annotated with the target annotation. (3) within: limits the package scope to scan.&#xA;Code Demo @Aspect @Component @Order(10) public class BidAuthorityProxy { /** * Scan classes under the specified package that are annotated with `@EnableRoleAuthority`. */ @Around(&amp;#34;@within(com.core.annotation.EnableRoleAuthority) &amp;amp;&amp;amp; within(com.bid..*)&amp;#34;) public Object verifyRoleExecuteCommand(ProceedingJoinPoint pjp) throws Throwable { // Get the intercepted method MethodSignature msig = (MethodSignature) pjp.</description>
    </item>
  </channel>
</rss>
