<?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 Margrop Blog</title>
    <link>https://blog.margrop.net/en/tag/spring/</link>
    <description>Recent content in Spring 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/spring/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>[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>
