<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Java on Margrop Blog</title>
    <link>https://blog.margrop.net/en/tag/java/</link>
    <description>Recent content in Java on Margrop Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Wed, 01 May 2024 13:34:09 +0800</lastBuildDate>
    <atom:link href="https://blog.margrop.net/en/tag/java/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>IDEA License Server Search Method</title>
      <link>https://blog.margrop.net/en/post/activate-jetbrains-intellij-idea/</link>
      <pubDate>Wed, 01 May 2024 13:34:09 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/activate-jetbrains-intellij-idea/</guid>
      <description>&lt;h1 id=&#34;please-search-for-yourself-using-the-search-engines-and-keywords-below&#34;&gt;Please search for yourself using the search engines and keywords below&lt;/h1&gt;&#xA;&lt;h2 id=&#34;fofahttpsenfofainfo&#34;&gt;&lt;a href=&#34;https://en.fofa.info/&#34;&gt;Fofa&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;header=&amp;#34;https://account.jetbrains.com/fls-auth&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;shodanhttpswwwshodanio&#34;&gt;&lt;a href=&#34;https://www.shodan.io/&#34;&gt;Shodan&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;Location&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;https://account.jetbrains.com/fls-auth&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;censyshttpscensyscom&#34;&gt;&lt;a href=&#34;https://censys.com/&#34;&gt;Censys&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;services.http.response.headers.location&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;account.jetbrains.com/fls-auth&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <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>MySQL Date and DST Conversion Error HOUR_OF_DAY: 0 -&gt; 1 and How to Fix It</title>
      <link>https://blog.margrop.net/en/post/mysql-exception-hour-of-day-0-1-solution/</link>
      <pubDate>Thu, 25 Mar 2021 10:53:15 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/mysql-exception-hour-of-day-0-1-solution/</guid>
      <description>&lt;h1 id=&#34;error-occurred-when-exporting-user-data-hour_of_day-0---1&#34;&gt;Error Occurred When Exporting User Data: HOUR_OF_DAY: 0 -&amp;gt; 1&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Exception in thread &amp;ldquo;main&amp;rdquo; java.lang.IllegalArgumentException: HOUR_OF_DAY: 0 -&amp;gt; 1&#xA;The full error message is as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;</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>How to Map JSON Objects Using Generic Hibernate Types</title>
      <link>https://blog.margrop.net/en/post/how-to-map-json-collections-using-jpa-and-hibernate/</link>
      <pubDate>Fri, 29 Jan 2021 16:06:09 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/how-to-map-json-collections-using-jpa-and-hibernate/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;&#xA;&lt;p&gt;In this article, we&amp;rsquo;ll see how to map JSON columns to JPA entity attributes using the &lt;a href=&#34;http://www.google.com/&#34; title=&#34;Hibernate Types&#34;&gt;Hibernate Types&lt;/a&gt; open-source project.&lt;/p&gt;&#xA;&lt;p&gt;While you can create your own custom Hibernate type to map JSON column types on Oracle, SQL Server, PostgreSQL, or MySQL, you don&amp;rsquo;t need to implement your own Hibernate Type since the Hibernate Types project already provides this functionality.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Solution to NumberFormatException when using SpringFox 3.0.0 version</title>
      <link>https://blog.margrop.net/en/post/java-springfox-number-format-exception/</link>
      <pubDate>Mon, 18 Jan 2021 16:39:34 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/java-springfox-number-format-exception/</guid>
      <description>I recently upgraded SpringFox to version 3.0.0, and a bunch of exceptions occurred when accessing the interface documentation.&#xA;The detailed exception stack is as follows&#xA;2021-01-18 16:25:35.824 WARN 62082 --- [ XNIO-2 task-1] i.s.m.p.AbstractSerializableParameter : Illegal DefaultValue null for parameter type integer java.lang.NumberFormatException: For input string: &amp;#34;&amp;#34; at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.base/java.lang.Long.parseLong(Long.java:702) at java.base/java.lang.Long.valueOf(Long.java:1144) at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) at jdk.internal.reflect.GeneratedMethodAccessor220.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:689) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) at com.</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>
