<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IntelliJ IDEA &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/intellij-idea/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Fri, 15 Mar 2024 12:59:03 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>[原创] 解决IntelliJ idea启动崩溃：error occurred during error reporting (), id 0x6, SIGABRT (0x6) at pc=...</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3intellij-idea%e5%90%af%e5%8a%a8%e5%b4%a9%e6%ba%83%ef%bc%9aerror-occurred-during-error-reporting-id-0x6-sigabrt-0x6-at-pc/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3intellij-idea%e5%90%af%e5%8a%a8%e5%b4%a9%e6%ba%83%ef%bc%9aerror-occurred-during-error-reporting-id-0x6-sigabrt-0x6-at-pc/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 15 Mar 2024 09:48:13 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[SIGABRT]]></category>
		<category><![CDATA[启动]]></category>
		<category><![CDATA[崩溃]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=14081</guid>

					<description><![CDATA[<div style="text-align: center;">
	<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2024/03/intellij_idea_logo.jpeg" style="width: 225px; height: 225px;" /></div>
<p>有时候，一个用了好久、一直好用的方法突然失灵，并且还折腾了几天，真的会逼疯人。<br />
前几天我就遇到了这种破事：在Ubuntu开发机上自己升级IntelliJ idea到最新版之后，就无法再启动它。<br />
启动时永远会崩溃，无论是重启系统、删除IntelliJ idea的本地缓存，或者使用回旧版，都无法再启动它（仿佛什么文件被&#34;污染&#34;了，再也回不去了），十分烦人。经过几天各种方法的尝试，终于解决了问题，我的解决办法不具有普适性，但如果你遇到了此类问题，或许可以为你提供一些解决思路。<br />
<span id="more-14081"></span><br />
OS：<span style="color:#0000ff;">Ubuntu 20.04.6 LTS</span><br />
JDK：<span style="color:#0000ff;">1.8.0_382</span><br />
原来安装的IntelliJ idea版本：<span style="color:#b22222;">idea-IC-232.8660.185</span><br />
从JetBrains官网上下载的新版IntelliJ idea版本：<span style="color:#b22222;">idea-IC-233.14808.21</span><br />
我当时不是利用IDE里的升级功能来升级的，而是自己下载了新版的压缩包，解压出来一个&#160;idea-IC-233.14808.21 目录，直接进入 bin 目录下执行 idea.sh 来跑的新版。众所周知，这样跑起来之后，新版会自动把旧版里的配置引入进来，只要没有问题，是可以无缝切换到新版不需要重新配置的。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然而，启动新版的时候挂了，最后看到命令行报错：</p>
<blockquote>
<div>
		[error occurred during error reporting (), id 0x6, SIGABRT (0x6) at pc=0x00007fed3c5cf00b]</div>
<div>
		Aborted (core dumped)</div>
</blockquote>
<div>
	进不了IDE主界面。同时在/home目录下生成了一个内容超长的错误报告文件 java_error_in_idea_xxx.log</div>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3intellij-idea%e5%90%af%e5%8a%a8%e5%b4%a9%e6%ba%83%ef%bc%9aerror-occurred-during-error-reporting-id-0x6-sigabrt-0x6-at-pc/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<div style="text-align: center;">
	<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2024/03/intellij_idea_logo.jpeg" style="width: 225px; height: 225px;" /></div>
<p>有时候，一个用了好久、一直好用的方法突然失灵，并且还折腾了几天，真的会逼疯人。<br />
前几天我就遇到了这种破事：在Ubuntu开发机上自己升级IntelliJ idea到最新版之后，就无法再启动它。<br />
启动时永远会崩溃，无论是重启系统、删除IntelliJ idea的本地缓存，或者使用回旧版，都无法再启动它（仿佛什么文件被&quot;污染&quot;了，再也回不去了），十分烦人。经过几天各种方法的尝试，终于解决了问题，我的解决办法不具有普适性，但如果你遇到了此类问题，或许可以为你提供一些解决思路。<br />
<span id="more-14081"></span><br />
OS：<span style="color:#0000ff;">Ubuntu 20.04.6 LTS</span><br />
JDK：<span style="color:#0000ff;">1.8.0_382</span><br />
原来安装的IntelliJ idea版本：<span style="color:#b22222;">idea-IC-232.8660.185</span><br />
从JetBrains官网上下载的新版IntelliJ idea版本：<span style="color:#b22222;">idea-IC-233.14808.21</span><br />
我当时不是利用IDE里的升级功能来升级的，而是自己下载了新版的压缩包，解压出来一个&nbsp;idea-IC-233.14808.21 目录，直接进入 bin 目录下执行 idea.sh 来跑的新版。众所周知，这样跑起来之后，新版会自动把旧版里的配置引入进来，只要没有问题，是可以无缝切换到新版不需要重新配置的。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然而，启动新版的时候挂了，最后看到命令行报错：</p>
<blockquote>
<div>
		[error occurred during error reporting (), id 0x6, SIGABRT (0x6) at pc=0x00007fed3c5cf00b]</div>
<div>
		Aborted (core dumped)</div>
</blockquote>
<div>
	进不了IDE主界面。同时在/home目录下生成了一个内容超长的错误报告文件 java_error_in_idea_xxx.log<br />
	我一开始并没有看这个log文件，而是按网上搜到的方法，分别尝试了：<br />
	1、重启系统<br />
	2、删除IntelliJ idea的缓存<br />
	3、使用回旧版IntelliJ idea<br />
	4、仿照<a href="https://youtrack.jetbrains.com/issue/IDEA-315192/IntelliJ-would-not-open-after-being-closed-once-on-Ubuntu-22.04-LTS.-The-only-solution-is-rebooting." rel="noopener" target="_blank">这个</a>类似的问题，卸载了snap又重新安装<br />
	以上方法都没用。<br />
	实在没辙了，只能硬着头皮看崩溃产生的日志文件&nbsp;java_error_in_idea_xxx.log，没想到一看就发现了端倪。<br />
	开头有一段内容是：</p>
<div>
<blockquote>
<div>
				# Problematic frame:</div>
<div>
				# C&nbsp; [x86_64-linux-gnu-tree-sitter-cpp.so+0x38ec09]&nbsp; tree_sitter_cpp_external_scanner_deserialize+0x179</div>
</blockquote>
<div>
<div>
				虽然我不知道它是什么确切的意思，但是这里写的是&quot;问题帧&quot;，说明崩溃和它有关。<br />
				<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a></div>
<div>
				再往下看日志，会看到：</p>
<blockquote>
<div>
						---------------&nbsp; T H R E A D&nbsp; ---------------</div>
<div>
						&nbsp;</div>
<div>
						Current thread (0x00007fec7c02b370):&nbsp; JavaThread &quot;AWT-EventQueue-0&quot; [_thread_in_native, id=352672, stack(0x00007feb95ae5000,0x00007feb95be6000)]</div>
<div>
						&nbsp;</div>
<div>
						Stack: [0x00007feb95ae5000,0x00007feb95be6000],&nbsp; sp=0x00007feb95be0310,&nbsp; free space=1004k</div>
<div>
						Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)</div>
<div>
						C&nbsp; [x86_64-linux-gnu-tree-sitter-cpp.so+0x38ec09]&nbsp; tree_sitter_cpp_external_scanner_deserialize+0x179</div>
<div>
						C&nbsp; [x86_64-linux-gnu-tree-sitter.so+0x30b3e]&nbsp; ts_parser_reset+0x30e</div>
<div>
						C&nbsp; [x86_64-linux-gnu-tree-sitter.so+0x2e329]&nbsp; ts_parser_set_language+0x399</div>
<div>
						C&nbsp; [x86_64-linux-gnu-tree-sitter.so+0xb4875]&nbsp; Java_org_treesitter_TSParser_ts_1parser_1set_1language+0x25</div>
<div>
						j&nbsp; org.treesitter.TSParser.ts_parser_set_language(JJ)Z+0</div>
<div>
						j&nbsp; org.treesitter.TSParser.setLanguage(Lorg/treesitter/TSLanguage;)Z+10</div>
<div>
						j&nbsp; ai.codegeex.plugin.lang.agent.d.a()V+64</div>
<div>
						j&nbsp; ai.codegeex.plugin.lang.agent.d.&lt;init&gt;()V+365</div>
<div>
						j&nbsp; ai.codegeex.plugin.lang.agent.d.a()Lai/codegeex/plugin/lang/agent/d;+10</div>
<div>
						j&nbsp; ai.codegeex.plugin.lang.agent.CodegeexAgentCompletionService.e()V+0</div>
<div>
						j&nbsp; ai.codegeex.plugin.lang.agent.CodegeexAgentCompletionService.&lt;init&gt;()V+266</div>
</blockquote>
<div>
<div>
						可见，和出问题的&quot;x86_64-linux-gnu-tree-sitter-cpp.so+0x38ec09&quot;有关系的插件，第一个出现的就是&quot;ai.codegeex.plugin&quot;，这个对应的就是我安装的CodeGeeX插件。</div>
<div>
						所以我怀疑，删除这个插件可以解决IntelliJ idea启动崩溃的问题。</div>
<div>
						在Ubuntu系统上，插件安装在这个目录下：<span style="color:#0000ff;">~/.local/share/JetBrains/IdeaIC2023.3</span></div>
<div>
						其中，IdeaIC2023.3是IntelliJ idea的版本号，每升级一个版本，~/.local/share/JetBrains 目录下都会生成一个新的目录。</div>
<div>
						在这个目录下，会看到有一个名为&quot;CodeGeeX&quot;的目录，这个目录就是CodeGeeX插件的安装目录，删除它即可。</div>
<div>
						然后再次尝试启动IntelliJ idea，发现已经可以正常启动了。<br />
						虽然我现在还不知道为什么CodeGeeX插件会引起这个问题，但是如果你像我一样，实在找不到IDE崩溃的原因时，删除可能有问题的插件或许是解决问题的一个办法。<br />
						<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
						<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
						转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
						感谢关注我的微信公众号（微信扫一扫）：<br />
						<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="color: rgb(77, 77, 77); font-size: 13px; width: 200px; height: 200px;" /><br />
						以及我的微信视频号：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
							<img decoding="async" alt="" src="https://www.codelast.com/wechat_shipinhao_qr_code.jpg" style="text-align: center; width: 200px; height: 199px;" /></p>
</p></div>
</p></div>
</p></div>
</p></div>
</p></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3intellij-idea%e5%90%af%e5%8a%a8%e5%b4%a9%e6%ba%83%ef%bc%9aerror-occurred-during-error-reporting-id-0x6-sigabrt-0x6-at-pc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 在IntelliJ IDEA中使用插件查看Maven conflict</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij-idea%e4%b8%ad%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9f%a5%e7%9c%8bmaven-conflict/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij-idea%e4%b8%ad%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9f%a5%e7%9c%8bmaven-conflict/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Wed, 24 Feb 2016 06:56:25 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[conflict]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Helper]]></category>
		<category><![CDATA[冲突]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=8721</guid>

					<description><![CDATA[<p>
如果Maven引入的jar包有冲突，可以使用IntelliJ IDEA的<a href="https://plugins.jetbrains.com/plugin/7179?pr=idea" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Maven Helper</span></a>插件来帮助分析。<br />
下面以<span style="color:#0000ff;">IntelliJ IDEA 15.0.3</span>为例，说明如何安装及使用这个插件。<br />
<span id="more-8721"></span><br />
<span style="background-color:#00ff00;">『1』</span>安装插件<br />
方法很简单，打开IntelliJ的 <span style="color:#b22222;">Settings</span><span style="color:#0000ff;">&#8594;</span><span style="color:#b22222;">Plugins</span><span style="color:#0000ff;">&#8594;</span><span style="color:#b22222;">Browser repositories</span>：<br />
<a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_1.png" style="width: 600px; height: 457px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
在搜索框中填入&#8220;maven helper&#8221;，会搜到这个插件，再点击右边的&#8220;Install&#8221;按钮（我已经安装过了，所以不会显示出这个按钮）：<br />
<a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_2.png" /></a><br />
安装好之后会让你重启IntelliJ IDEA，插件才能生效。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『2』</span>使用插件<br />
在IntelliJ中打开项目的pom.xml文件，在文件编辑器的左下方，会看到两个tab，一个是&#8220;<span style="color:#0000ff;">Text</span>&#8221;，另一个是&#8220;<span style="color:#0000ff;">Dependency Analyzer</span>&#8221;：<br />
<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_3.png" /></p>
<p>打开&#8220;Dependency Analyzer&#8221;，有可能你看到的会是这样一幅画面：<br />
<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_4.png" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
根据图中的错误提示，我们可以找到 <a href="https://youtrack.jetbrains.com/issue/IDEA-133331" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">IDEA-133331</span></a> 这个issue的问题，根据里面的描述，为了修正这个问题，我们可以这样干：<br />
在IntelliJ的&#160;<span style="color: rgb(178, 34, 34);">Settings</span><span style="color: rgb(0, 0, 255);">&#8594;</span><span style="color: rgb(178, 34, 34);">Build, Execution, Deployment</span><span style="color: rgb(0, 0, 255);">&#8594;</span><span style="color: rgb(178, 34, 34);">Build Tools</span><span style="color: rgb(0, 0, 255);">&#8594;</span><span style="color: rgb(178, 34, 34);">Maven</span><span style="color: rgb(0, 0, 255);">&#8594;</span><span style="color: rgb(178, 34, 34);">Importing</span><span style="color: rgb(178, 34, 34);">&#160;</span>中，为&#8220;VM options for importer&#8221;添加上&#8220;<span style="color:#0000ff;">-Didea.maven3.use.compat.resolver</span>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij-idea%e4%b8%ad%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9f%a5%e7%9c%8bmaven-conflict/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
如果Maven引入的jar包有冲突，可以使用IntelliJ IDEA的<a href="https://plugins.jetbrains.com/plugin/7179?pr=idea" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Maven Helper</span></a>插件来帮助分析。<br />
下面以<span style="color:#0000ff;">IntelliJ IDEA 15.0.3</span>为例，说明如何安装及使用这个插件。<br />
<span id="more-8721"></span><br />
<span style="background-color:#00ff00;">『1』</span>安装插件<br />
方法很简单，打开IntelliJ的 <span style="color:#b22222;">Settings</span><span style="color:#0000ff;">&rarr;</span><span style="color:#b22222;">Plugins</span><span style="color:#0000ff;">&rarr;</span><span style="color:#b22222;">Browser repositories</span>：<br />
<a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_1.png" style="width: 600px; height: 457px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
在搜索框中填入&ldquo;maven helper&rdquo;，会搜到这个插件，再点击右边的&ldquo;Install&rdquo;按钮（我已经安装过了，所以不会显示出这个按钮）：<br />
<a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_2.png" /></a><br />
安装好之后会让你重启IntelliJ IDEA，插件才能生效。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『2』</span>使用插件<br />
在IntelliJ中打开项目的pom.xml文件，在文件编辑器的左下方，会看到两个tab，一个是&ldquo;<span style="color:#0000ff;">Text</span>&rdquo;，另一个是&ldquo;<span style="color:#0000ff;">Dependency Analyzer</span>&rdquo;：<br />
<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_3.png" /></p>
<p>打开&ldquo;Dependency Analyzer&rdquo;，有可能你看到的会是这样一幅画面：<br />
<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2016/02/intellij_maven_helper_4.png" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
根据图中的错误提示，我们可以找到 <a href="https://youtrack.jetbrains.com/issue/IDEA-133331" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">IDEA-133331</span></a> 这个issue的问题，根据里面的描述，为了修正这个问题，我们可以这样干：<br />
在IntelliJ的&nbsp;<span style="color: rgb(178, 34, 34);">Settings</span><span style="color: rgb(0, 0, 255);">&rarr;</span><span style="color: rgb(178, 34, 34);">Build, Execution, Deployment</span><span style="color: rgb(0, 0, 255);">&rarr;</span><span style="color: rgb(178, 34, 34);">Build Tools</span><span style="color: rgb(0, 0, 255);">&rarr;</span><span style="color: rgb(178, 34, 34);">Maven</span><span style="color: rgb(0, 0, 255);">&rarr;</span><span style="color: rgb(178, 34, 34);">Importing</span><span style="color: rgb(178, 34, 34);">&nbsp;</span>中，为&ldquo;VM options for importer&rdquo;添加上&ldquo;<span style="color:#0000ff;">-Didea.maven3.use.compat.resolver</span>&rdquo;参数，例如，原来我的这个参数为&ldquo;-Xmx512m&nbsp;&rdquo;，修改之后变成了：</p>
<blockquote>
<p>
		-Xmx512m -Didea.maven3.use.compat.resolver</p>
</blockquote>
<p>注意，根据上面提到的issue链接里的描述，这个参数修改对不同的IntelliJ版本是不同的。<br />
这样修改之后，就可以看到Dependency Analyzer结果了。</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij-idea%e4%b8%ad%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9f%a5%e7%9c%8bmaven-conflict/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创]Java基础知识记录（2）</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9bjava%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e8%ae%b0%e5%bd%95%ef%bc%882%ef%bc%89/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9bjava%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e8%ae%b0%e5%bd%95%ef%bc%882%ef%bc%89/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Wed, 10 Apr 2013 03:12:44 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java基础]]></category>
		<category><![CDATA[红色]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=5780</guid>

					<description><![CDATA[<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">前言：本文『很傻很天真』，任何稍有Java编程经验的都不用看了。</span><br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color:#ff0000;"><span style="background-color:#00ff00;">▶</span></span>&#160;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">创建一个Set时，如何初始化其中的元素<br />
如果在创建一个Set之后，再用add()方法向Set中添加元素，就显得比较麻烦了。通过使用<a href="https://code.google.com/p/guava-libraries/" rel="noopener noreferrer" target="_blank">Google Guava</a>库，可以在初始化的时候就向其添加若干元素：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">Set&#60;String&#62;&#160;s&#160;=&#160;Sets.newHashSet(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#34;99&#34;</span>,&#160;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#34;100&#34;</span>)
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">这样创建出的s就会包含99和100这两个元素。</span><br />
<span id="more-5780"></span><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);">▶</span></span>&#160;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">jar包中的.class文件，为什么有的文件名类似于 ***$1.class</span></p>
<div>
	<span style="font-family:arial,helvetica,sans-serif;"><span style="font-size: 14px;">$后面跟数字是匿名类编译出来的，$后面跟文字是内部类编译出来的。</span></span></div>
<p><span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);">▶</span></span>&#160;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">java.lang.OutOfMemoryError: GC overhead limit exceeded错误</span><br />
<span style="font-size: 14.399999618530273px;">出现这个错误的时候，程序可能接着就挂掉了。要关掉该功能，可以在程序启动的时候传入参数：</span></p>
<blockquote>
<p>
		java -XX:-UseGCOverheadLimit (后面省略)</p>
</blockquote>
<p>
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);">▶</span></span>&#160;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">使用Log4j打印格式化的字符串时的高效率写法<br />
如果你使用Log4j来打印日志，字符串中需要format一些变量，例如：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">int</span>&#160;countNum&#160;=&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">9999</span>;
LOG.debug(String.format(</code></pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9bjava%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e8%ae%b0%e5%bd%95%ef%bc%882%ef%bc%89/" class="read-more">Read More </a></section>]]></description>
										<content:encoded><![CDATA[<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">前言：本文『很傻很天真』，任何稍有Java编程经验的都不用看了。</span><br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color:#ff0000;"><span style="background-color:#00ff00;"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">创建一个Set时，如何初始化其中的元素<br />
如果在创建一个Set之后，再用add()方法向Set中添加元素，就显得比较麻烦了。通过使用<a href="https://code.google.com/p/guava-libraries/" rel="noopener noreferrer" target="_blank">Google Guava</a>库，可以在初始化的时候就向其添加若干元素：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">Set&lt;String&gt;&nbsp;s&nbsp;=&nbsp;Sets.newHashSet(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;99&quot;</span>,&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;100&quot;</span>)
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">这样创建出的s就会包含99和100这两个元素。</span><br />
<span id="more-5780"></span><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">jar包中的.class文件，为什么有的文件名类似于 ***$1.class</span></p>
<div>
	<span style="font-family:arial,helvetica,sans-serif;"><span style="font-size: 14px;">$后面跟数字是匿名类编译出来的，$后面跟文字是内部类编译出来的。</span></span></div>
<p><span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">java.lang.OutOfMemoryError: GC overhead limit exceeded错误</span><br />
<span style="font-size: 14.399999618530273px;">出现这个错误的时候，程序可能接着就挂掉了。要关掉该功能，可以在程序启动的时候传入参数：</span></p>
<blockquote>
<p>
		java -XX:-UseGCOverheadLimit (后面省略)</p>
</blockquote>
<p>
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">使用Log4j打印格式化的字符串时的高效率写法<br />
如果你使用Log4j来打印日志，字符串中需要format一些变量，例如：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">int</span>&nbsp;countNum&nbsp;=&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">9999</span>;
LOG.debug(String.format(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;Count:&nbsp;%d&quot;</span>,&nbsp;countNum));
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">这样并不是最有效率的写法，如下写法更高效：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">int</span>&nbsp;countNum&nbsp;=&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">9999</span>;
LOG.debug(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;Count:&nbsp;{}&quot;</span>,&nbsp;countNum);
</code></pre>
</section>
<p>
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">单元测试时，提示&ldquo;</span>java.lang.SecurityException: Prohibited package name: java.com.xxx<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">&rdquo;错误的原因<br />
这是因为package名不能以java开头，修改后再重新运行单元测试即可解决此问题。</span><br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">同一个jar包中的多个client程序，有一个client能连上Zookeeper server的解决办法<br />
我最后还是没找到原因，但是解决了。可以尝试如下解决办法：</span><br />
①用 ps -ef | grep zookeeper 查看当前有几个Zookeeper进程，如果可以的话，把它们全部kill掉，再用Zookeeper安装目录下的 bin/zkServer.sh 脚本来启动。在启动之前，修改 conf/zoo.cfg 配置文件，添加如下一行：</p>
<blockquote>
<p>
		maxClientCnxns=300</p>
</blockquote>
<p>此参数含义为：<br />
单个客户端与单台服务器之间的连接数的限制，是IP级别的，默认是60，如果设置为0，那么表明不作任何限制。请注意这个限制的使用范围，仅仅是单台客户端机器与单台Zookeeper服务器之间的连接数限制，不是针对指定客户端IP，也不是ZK集群的连接数限制，也不是单台ZK对所有客户端的连接数限制。<br />
②用&nbsp;<span style="font-family: 文泉驿等宽微米黑;">bin/zkServer.sh 脚本来启动 Zookeeper server：</span></p>
<blockquote>
<p>
		./zkServer.sh start</p>
</blockquote>
<p>③查看server是否已经启动了，如果是，则重新用client程序连接Zookeeper server。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">Java正则截取书名号里的内容<br />
假设有如下字符串：<br />
</span></p>
<blockquote>
<p>
		<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">今天去看好评如潮的《变形金刚》这部电影</span></p>
</blockquote>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">那么要获取书名号里的内容&ldquo;变形金刚&rdquo;，可以用Java这样干：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">Pattern&nbsp;MY_PATTERN&nbsp;=&nbsp;Pattern.compile(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;.*《(.+)》.*&quot;</span>);

String&nbsp;str&nbsp;=&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;今天去看好评如潮的《变形金刚》这部电影&quot;</span>;
String&nbsp;result&nbsp;=&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;&quot;</span>;

Matcher&nbsp;matcher&nbsp;=&nbsp;MY_PATTERN.matcher(str);
<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">if</span>&nbsp;(matcher.matches())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;matcher.group(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>);
}
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">结果就保存在了result中。</span><br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">Java计算一个字符串的MD5值</span><br />
<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">用</span>org.apache.commons.codec.digest<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">包（jar包名类似于</span>commons-codec-1.6.jar<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">）中的</span><span style="color:#0000ff;">DigestUtils.md5Hex()</span>方法来计算是最方便的，不要自己去费时间地写了：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">String&nbsp;md5&nbsp;=&nbsp;DigestUtils.md5Hex(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;abcdefg&quot;</span>);
System.out.println(md5);
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">结果：</span>7ac66c0f148de9519b8bd264312c4d64</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">Maven下载回来的依赖jar包的默认路径<br />
一个Java项目用Maven编译的话，会自动下载回来依赖的jar包，这些jar包如果不在当前路径下，可能在哪里呢？<br />
如果你没配置过的话，应该是在默认路径下：<br />
<span style="color:#0000ff;">/home/you_user/.m2/</span><br />
到这个隐藏路径下搜索那些jar包吧。</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;Class.forName 和 ClassLoader.loadClass的区别<br />
这两个方法都可以动态地加载一个类。<br />
之所以要&ldquo;动态&rdquo;地加载，是因为有时我们无法预先知道要加载的类是什么，例如，某文件中写了一个类名com.codelast.MyClassA，在读取这个文件之后，我才知道要加载的是类<span style="font-family: 文泉驿等宽微米黑;">MyClassA</span>，因此，我无法在程序中写诸如&nbsp;<span style="font-family: 文泉驿等宽微米黑;">MyClassA</span>&nbsp;a = new&nbsp;<span style="font-family: 文泉驿等宽微米黑;">MyClassA</span>(); 这样的代码来创建一个类<span style="font-family: 文泉驿等宽微米黑;">MyClassA</span>的对象，因能&ldquo;动态&rdquo;地加载类<span style="font-family: 文泉驿等宽微米黑;">MyClassA</span>，然后创建一个对象。<br />
但是，这两种加载类的方法的区别是什么呢？<br />
区别在于：Class.forName除了加载类到JVM中，还会执行类的静态初始化；而ClassLoader.loadClass不会执行类的初始化，只是在类被第一次使用时才会进行类的初始化。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: 文泉驿等宽微米黑;">一个Linux文件的</span>toURI()和toURL()的结果有什么不同<br />
如下代码：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">File&nbsp;f&nbsp;=&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">new</span>&nbsp;File(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;/opt/python3.3/bin/python3.3&quot;</span>);
System.out.println(f.toURI());
System.out.println(f.toURI().toURL());
</code></pre>
</section>
<p>输出结果为：</p>
<blockquote>
<div>
		file:/opt/python3.3/bin/python3.3</div>
<div>
		file:/opt/python3.3/bin/python3.3</div>
</blockquote>
<p>可见没有不同。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: 文泉驿等宽微米黑;">为什么要用</span>URLClassLoader来加载类<br />
在某些代码中，会看到用URLClassLoader来加载类，这货与用Class.forName加载类有何区别？<br />
<span style="font-family: 文泉驿等宽微米黑;">URLClassLoader可以从根据指定的路径搜索到的.class文件，或者根据.jar包中的class来加载类。它就不像</span>Class.forName那样要按包名的方式（例如 <span style="color:#0000ff;">Class t = Class.forName(&quot;java.lang.Thread&quot;)</span>）才能加载一个类了。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: 文泉驿等宽微米黑;">IntelliJ的控制台/console 里的中文显示乱码问题<br />
很久很久以前的IntelliJ是没有这个问题的，后来不记得从哪个版本开始有这个问题了：运行单元测试或main方法时，在控制台输出的中文是乱码的。<br />
解决办法：<br />
菜单&ldquo;Run&rdquo;&rarr;&ldquo;Configurations&rdquo;，在对应的类的&ldquo;VM options&rdquo;中添加：</span></p>
<blockquote>
<p>
		-Dfile.encoding=GB2312</p>
</blockquote>
<p>会发现乱码问题就解决了。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;用Ant打包文件时，要打包一个目录下的所有文件的表示方法 / 排除指定文件的表示方法<br />
假设你想把一个目录下的所有文件打进一个jar包里，在build.xml中可以这样写：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="xml language-xml hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">jar</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">jarfile</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;package.jar&quot;</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">fileset</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">dir</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;.&quot;</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">includes</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;conf/**/*&quot;</span>/&gt;
</span>
<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">jar</span>&gt;</span></code></pre>
</section>
<p>这样就会把当前目录下的&ldquo;conf&rdquo;目录下的目录（包括子目录）和文件打进jar包中。<br />
如果要把conf目录下的一个特定文件&nbsp;log4j.properties 排除掉（不打进jar包里）呢？可以这样：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="xml language-xml hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">jar</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">jarfile</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;package.jar&quot;</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">fileset</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">dir</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;.&quot;</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">includes</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;conf/**/*&quot;</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">exclude</span>&nbsp;<span class="hljs-attr" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(165, 218, 45); word-wrap: inherit !important; word-break: inherit !important;">name</span>=<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;conf/log4j.*&quot;</span>/&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">fileset</span>&gt;
</span>
<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">jar</span>&gt;</span></code></pre>
</section>
<p>其中，exclude 就是用来排除的，这里把所有符合 log4j.* 这个pattern的文件都排除掉了。<br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;IntelliJ IDEA 13.1不支持subversion 1.8的问题<br />
Ubuntu 14.04用apt-get install安装上的svn已经是1.8.8的版本，如果你没有做过特殊设置，并且使用IntelliJ IDEA中的subversion相关功能（例如compare with latest repository version），会发现提示错误：</p>
<blockquote>
<p>
		Error:svn: E155021: This client is too old to work with the working copy at &#39;/home/codelast/xxx&#39; (format &#39;31&#39;).</p>
</blockquote>
<p>解决这个问题并不需要重新安装低版本的subversion（那样实在太二了），而是在IntelliJ中设置一下就好了：<br />
<span style="color:#0000ff;">Settings&rarr;Version Control&rarr;Subversion&rarr;勾选上&ldquo;Use command line client: svn&rdquo;</span><br />
这样就会告诉IntelliJ使用命令行客户端svn（也就是你安装的subversion 1.8.x）来执行subversion相关功能，这样就没有任何问题了。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;如何转换long到byte数组<br />
别折腾了，直接用<a href="https://code.google.com/p/guava-libraries/" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">Google Guava</span></a>库中的方法来转，一句话就可以解决：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">byte</span>[]&nbsp;converted&nbsp;=&nbsp;Longs.toByteArray(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">123L</span>);
</code></pre>
</section>
<p>简单得不能更简单了。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;求两个Set的交集<br />
用<a href="https://code.google.com/p/guava-libraries/" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">Google Guava</span></a>库，这个问题就变得无比简单了：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">Set&lt;Integer&gt;&nbsp;set1&nbsp;=&nbsp;Sets.newHashSet(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">2</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">3</span>);
Set&lt;Integer&gt;&nbsp;set2&nbsp;=&nbsp;Sets.newHashSet(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">2</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">3</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">4</span>);
Set&lt;Integer&gt;&nbsp;intersectedSet&nbsp;=&nbsp;Sets.intersection(set1,&nbsp;set2);
System.out.println(intersectedSet);
</code></pre>
</section>
<p>输出：</p>
<blockquote>
<p>
		[2, 3]</p>
</blockquote>
<p>
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;启动Zookeeper时指定配置文件<br />
只需要简单地使用 bin 目录下的&nbsp;zkServer.sh 脚本就可以了：</p>
<blockquote>
<p>
		./zkServer.sh start ../conf/zoo.cfg</p>
</blockquote>
<p>这表示用上一级目录下的 conf 目录下的 zoo.cfg 文件作为配置文件来启动Zookeeper。<br />
<span style="font-size: 14.399999618530273px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.399999618530273px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">如何让IntelliJ识别JSP代码里的request<br />
如果你发现用IntelliJ idea无法识别JSP代码中的request对象（因此也就无法识别其方法），例如：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">String&nbsp;id&nbsp;=&nbsp;request.getParameter(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;oneId&quot;</span>);
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.399999618530273px;">这个request对象是HttpServletRequest类的实例，它实现了ServletRequest接口。确实，就算IntelliJ不能识别它，你可以把这个JSP文件部署到Tomcat中让它正确运行，但是写代码的时候多难受啊！其实，你只需要下载一个javax.servlet的jar包，添加到IntelliJ的项目的lib中，就可以了，例如javax.servlet-3.0.jar</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">ant test如何单独运行一个UT class？<br />
在一个Java工程下，ant test命令会运行全部的test case，但是如果我们只想运行一个UT class的话，可以这样：</span></p>
<blockquote>
<p>
		ant test -Dtestcase=MyTest</p>
</blockquote>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">这就会单独运行MyTest这个类名的UT。</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">Maven编译时跳过单元测试</span></p>
<blockquote>
<p>
		mvn clean install -DskipTests</p>
</blockquote>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">注意大小写。</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">JDK8下的ScriptEngine返回 null 的问题<br />
如果你在Java中执行JavaScript脚本／代码，那么你可能会写类似于下面的代码：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">ScriptEngineManager&nbsp;scriptEngineMgr&nbsp;=&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">new</span>&nbsp;ScriptEngineManager();
ScriptEngine&nbsp;engine&nbsp;=&nbsp;scriptEngineMgr.getEngineByName(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;JavaScript&quot;</span>);
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">这些代码在JDK6下运行得很好，但是在JDK8下，你就会发现 engine 变量为null。<br />
首先，从JDK6升级到JDK8，engine name已经不是&ldquo;JavaScript&rdquo;而是&ldquo;nashorn&rdquo;了，其次，上面的代码还要做一些修改，如下：</span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="java language-java hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">ScriptEngine&nbsp;engine&nbsp;=&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">new</span>&nbsp;ScriptEngineManager(<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">null</span>).getEngineByName(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&quot;nashorn&quot;</span>);
</code></pre>
</section>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">具体请看<a href="http://stackoverflow.com/questions/25332640/getenginebynamenashorn-returns-null" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">这个</span></a>链接。<br />
这样修改之后就OK了。</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: 14.4px;">Zookeeper客户端脚本zkCli.sh删除Zookeeper中一个节点（node）的方法</span><br />
<span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">旧版的zkCli.sh只能删除里面没有下级node的节点，用下面的方法：</span></p>
<blockquote>
<p>
		[zk: zk.codelast.com:2191(CONNECTED) 1] delete node_to_del</p>
</blockquote>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">如果<span style="color:#0000ff;">node_to_del</span>下面还有其他节点（即非空），会提示一个错误，说里面非空，不允许删除。要递归删除，只能自己写个程序了。</span><br />
<span style="font-size: 14.4px; color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" style="font-size: 14.4px;" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">而新版的zkCli.sh可以删除里面非空的节点，用下面的方法：</span></p>
<blockquote>
<p>
		[zk: zk.codelast.com:2191(CONNECTED) 1] rmr node_to_del</p>
</blockquote>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 14.3999996185303px;">其中，<span style="color:#0000ff;">node_to_del</span>节点里面可以非空。</span></p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;IntelliJ IDEA里，一个项目的所有外部依赖包都无法识别（全部红色），怎么办？<br />
这是一个非常恼人的问题，我在网上搜了很多办法都没用，包括清除缓存，重新import&nbsp;maven项目，等等，能用的招都试了一遍，但是对自己电脑上的某些特定项目，它就是有这个问题。IntelliJ IDEA的论坛里那些讨论帖子里也有很多人反映一样的问题。<br />
最后，是添加了一个 ~/.m2/settings.xml&nbsp;文件，在里面添加了某些内容之后治好的，其中有一段关键的代码是：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="xml language-xml hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">mirror</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">id</span>&gt;</span>maven-central<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">id</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">mirrorOf</span>&gt;</span>central<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">mirrorOf</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">url</span>&gt;</span>http://xxx.codelast.com/repositories/releases<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">url</span>&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">&lt;/<span class="hljs-name" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">mirror</span>&gt;</span></code></pre>
</section>
<p>其中，上面的&ldquo;url&rdquo;字段要视情况改成适合你用的。</p>
<p><span style="color: rgb(255, 0, 0);"><span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></span>&nbsp;对一个list中的元素排序，排序依据是元素对象的一个double字段(从大到小)</p>
<pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'JetBrains Mono',monospace;font-size:12.0pt;">
<span style="color:#bbb529;">@Test
</span><span style="color:#cc7832;">public void </span><span style="color:#ffc66d;">test</span>() <span style="color:#cc7832;">throws </span>Exception {
  <span style="color:#808080;">// </span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">测试对一个</span><span style="color:#808080;">list</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">中的元素排序</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">，排序依据是元素对象的一个</span><span style="color:#808080;">double</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">字段</span>(<span style="font-size: 12pt; color: rgb(128, 128, 128); font-family: &quot;DejaVu Sans Mono&quot;, monospace;">从小到大</span><span style="font-size: 12pt; color: rgb(128, 128, 128);">)</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">
</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">  </span>CustomObject object1 = <span style="color:#cc7832;">new </span>CustomObject().setField(<span style="color:#6897bb;">2.0</span>)<span style="color:#cc7832;">;
</span><span style="color:#cc7832;">  </span>CustomObject object2 = <span style="color:#cc7832;">new </span>CustomObject().setField(<span style="color:#6897bb;">1.0</span>)<span style="color:#cc7832;">;
</span><span style="color:#cc7832;">  </span>CustomObject object3 = <span style="color:#cc7832;">new </span>CustomObject().setField(<span style="color:#6897bb;">3.0</span>)<span style="color:#cc7832;">;
</span>
<span style="color:#cc7832;">  </span>List&lt;CustomObject&gt; list = Lists.<span style="font-style:italic;">newArrayList</span>(object1<span style="color:#cc7832;">, </span>object2<span style="color:#cc7832;">, </span>object3)<span style="color:#cc7832;">;
</span><span style="color:#cc7832;">  </span>list.sort(Comparator.<span style="font-style:italic;">comparingDouble</span>(CustomObject::getField))<span style="color:#cc7832;">;
</span><span style="color:#cc7832;">  </span><span style="color:#808080;">//Collections.reverse(list);  // </span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">如果需要的话，再把排好序的</span><span style="color:#808080;">list</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">逆序
</span><span style="color:#808080;font-family:'DejaVu Sans Mono',monospace;">  </span><span style="color:#cc7832;">for </span>(CustomObject object : list) {
    System.<span style="color:#9876aa;font-style:italic;">out</span>.println(object.getField())<span style="color:#cc7832;">;
</span><span style="color:#cc7832;">  </span>}
}

<span style="color:#bbb529;">@Data
</span><span style="color:#bbb529;">@Accessors</span>(chain = <span style="color:#cc7832;">true</span>)
<span style="color:#cc7832;">private static class </span>CustomObject {
  <span style="color:#cc7832;">private double </span><span style="color:#9876aa;">field</span><span style="color:#cc7832;">;
</span>}</pre>
<p>输出：</p>
<blockquote>
<div>
		1.0</div>
<div>
		2.0</div>
<div>
		3.0</div>
</blockquote>
<p>上面的代码是在UT中写的，CustomObject的两个annotation：@Data 和 @Accessors(chain = true) 都来自于 lombok 库。</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /><br />
	&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9bjava%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e8%ae%b0%e5%bd%95%ef%bc%882%ef%bc%89/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
