<?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 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/intellij/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Tue, 07 Jun 2022 03:30:07 +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 JAVA项目里一堆class找不到定义(标红)的解决办法</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea-java%e9%a1%b9%e7%9b%ae%e9%87%8c%e4%b8%80%e5%a0%86class%e6%89%be%e4%b8%8d%e5%88%b0%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ba%a2%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea-java%e9%a1%b9%e7%9b%ae%e9%87%8c%e4%b8%80%e5%a0%86class%e6%89%be%e4%b8%8d%e5%88%b0%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ba%a2%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 07 Jun 2022 03:29:09 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[undefined]]></category>
		<category><![CDATA[标红]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13601</guid>

					<description><![CDATA[<p>
	依次尝试以下方法，如果一个不行就试另外一个。</p>
<ul>
<li>
		方法1</li>
</ul>
<p>
	点击菜单 File&#8594; Invalidate Caches，即清空IntelliJ的缓存，这个操作会要求重启IntelliJ，重启之后会需要一些时间重新缓存各种lib。</p>
<p>
<span id="more-13601"></span></p>
<ul>
<li>
		方法2</li>
</ul>
<p>
	先在IntelliJ里面执行Maven-&#62;clean，再执行 Reload All Maven Projects，就好了（如下图）。</p>
<p>
	这个问题是IntelliJ的bug，对 maven extension 兼容有点问题。<br />
	<img decoding="async" alt="inltellij maven problem" src="https://www.codelast.com/wp-content/uploads/2022/01/intellij_maven_problem.jpeg" style="width: 350px; height: 551px;" /></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>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<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>&#160;<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;" />&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea-java%e9%a1%b9%e7%9b%ae%e9%87%8c%e4%b8%80%e5%a0%86class%e6%89%be%e4%b8%8d%e5%88%b0%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ba%a2%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	依次尝试以下方法，如果一个不行就试另外一个。</p>
<ul>
<li>
		方法1</li>
</ul>
<p>
	点击菜单 File&rarr; Invalidate Caches，即清空IntelliJ的缓存，这个操作会要求重启IntelliJ，重启之后会需要一些时间重新缓存各种lib。</p>
<p>
<span id="more-13601"></span></p>
<ul>
<li>
		方法2</li>
</ul>
<p>
	先在IntelliJ里面执行Maven-&gt;clean，再执行 Reload All Maven Projects，就好了（如下图）。</p>
<p>
	这个问题是IntelliJ的bug，对 maven extension 兼容有点问题。<br />
	<img decoding="async" alt="inltellij maven problem" src="https://www.codelast.com/wp-content/uploads/2022/01/intellij_maven_problem.jpeg" style="width: 350px; height: 551px;" /></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 />
	感谢关注我的微信公众号（微信扫一扫）：<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>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea-java%e9%a1%b9%e7%9b%ae%e9%87%8c%e4%b8%80%e5%a0%86class%e6%89%be%e4%b8%8d%e5%88%b0%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ba%a2%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 在IntelliJ中运行Java unit test(单元测试)时打印出&quot;log4j:ERROR Either File or DatePattern options are not set for appender&quot;的问题</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij%e4%b8%ad%e8%bf%90%e8%a1%8cjava-unit-test%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e6%97%b6%e6%89%93%e5%8d%b0%e5%87%balog4jerror-either-file-or-datepattern-option/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij%e4%b8%ad%e8%bf%90%e8%a1%8cjava-unit-test%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e6%97%b6%e6%89%93%e5%8d%b0%e5%87%balog4jerror-either-file-or-datepattern-option/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 28 Jan 2022 18:52:18 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[单元测试]]></category>
		<category><![CDATA[日志]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13449</guid>

					<description><![CDATA[<p>当你在IntelliJ&#160;idea中跑一个Java单元测试时，可能会发现单元测试本身没有任何问题，可以成功执行，但是IntelliJ的日志输出窗口里却打印出大量的&#8220;错误&#8221;日志，类似于下面这样：<br />
<span id="more-13449"></span></p>
<blockquote>
<div>
		<span style="font-size:14px;">log4j:ERROR setFile(null,true) call failed.</span></div>
<div>
		<span style="font-size:14px;">java.io.FileNotFoundException: / (Is a directory)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.open0(Native Method)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.open(FileOutputStream.java:270)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.&#60;init&#62;(FileOutputStream.java:213)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.&#60;init&#62;(FileOutputStream.java:133)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)</span></div></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij%e4%b8%ad%e8%bf%90%e8%a1%8cjava-unit-test%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e6%97%b6%e6%89%93%e5%8d%b0%e5%87%balog4jerror-either-file-or-datepattern-option/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>当你在IntelliJ&nbsp;idea中跑一个Java单元测试时，可能会发现单元测试本身没有任何问题，可以成功执行，但是IntelliJ的日志输出窗口里却打印出大量的&ldquo;错误&rdquo;日志，类似于下面这样：<br />
<span id="more-13449"></span></p>
<blockquote>
<div>
		<span style="font-size:14px;">log4j:ERROR setFile(null,true) call failed.</span></div>
<div>
		<span style="font-size:14px;">java.io.FileNotFoundException: / (Is a directory)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.open0(Native Method)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.open(FileOutputStream.java:270)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)</span></div>
<div>
		<span style="font-size:14px;">at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:133)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)</span></div>
<div>
		<span style="font-size:14px;">at org.apache.log4j.LogManager.&lt;clinit&gt;(LogManager.java:127)</span></div>
<div>
		<span style="font-size:14px;">at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:66)</span></div>
<div>
		<span style="font-size:14px;">at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)</span></div>
<div>
		<span style="font-size:14px;">at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)</span></div>
<div>
		<span style="font-size:14px;">&nbsp; &nbsp; (后面很长，省略)</span></div>
<div>
		<span style="font-size:14px;"><span style="color:#ff0000;">log4j:ERROR Either File or DatePattern options are not set for appender [LOCAL].</span></span></div>
</blockquote>
<p>这和你的单元测试没有任何关系，它是因为程序中使用的日志库&nbsp;log4j 在默认的路径下找不到log4j配置文件导致的。如果你的项目使用了标准的目录布局，那么应该在 <span style="color:#0000ff;">resources</span>&nbsp;目录下有一个&nbsp;<span style="color:#0000ff;">log4j.properties</span>&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="javascript language-javascript 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;test
&nbsp;&nbsp;&nbsp;&nbsp;├──&nbsp;java
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp;&nbsp;└──&nbsp;com
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└──&nbsp;codelast
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└──&nbsp;MyUnitTest.java
&nbsp;&nbsp;&nbsp;&nbsp;└──&nbsp;resources
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└──&nbsp;log4j.properties
</code></pre>
</section>
<p> 其中 test 目录下存放所有和单元测试相关的代码文件以及配置文件，下面有两个平级的目录：java 和 resources。<br />
log4j.properties文件的内容：</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="javascript language-javascript 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;">log4j.rootLogger=INFO,stdout
log4j.appender.stdout&nbsp;=&nbsp;org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target&nbsp;=&nbsp;System.out
log4j.appender.stdout.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern&nbsp;=&nbsp;%d{<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;">HH</span>:mm:ss}&nbsp;[%p]:%m%n
</code></pre>
</section>
<p>这样你再运行 IntelliJ 里的单元测试，就不会打印出上面那些超长的错误日志了。<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>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8intellij%e4%b8%ad%e8%bf%90%e8%a1%8cjava-unit-test%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e6%97%b6%e6%89%93%e5%8d%b0%e5%87%balog4jerror-either-file-or-datepattern-option/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] IntelliJ推出的语法检查插件Grazie，没有现实意义</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij%e6%8e%a8%e5%87%ba%e7%9a%84%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5%e6%8f%92%e4%bb%b6grazie%ef%bc%8c%e6%b2%a1%e6%9c%89%e7%8e%b0%e5%ae%9e%e6%84%8f%e4%b9%89/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij%e6%8e%a8%e5%87%ba%e7%9a%84%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5%e6%8f%92%e4%bb%b6grazie%ef%bc%8c%e6%b2%a1%e6%9c%89%e7%8e%b0%e5%ae%9e%e6%84%8f%e4%b9%89/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 09 Nov 2019 16:46:07 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[Grazie]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[语法检查]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=10792</guid>

					<description><![CDATA[<p>
今天看到一篇推送的技术文章，说IntelliJ推出了一个语法检查插件<a href="https://blog.jetbrains.com/idea/2019/11/meet-grazie-the-ultimate-spelling-grammar-and-style-checker-for-intellij-idea/" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">Grazie</span></a>，但它不是用于检查面向编译器的语法，而是用于检查面向人类的语法，比如引号里的字符串、注释语句里的语法，等等。我认为在当前的环境下，它没有意义&#8212;&#8212;除非在一个有着严格要求(或者非常自律)的团队里，否则这种功能只能用来&#8220;折腾自己&#8221;，而不可能改善大家整体的代码状况。<br />
<span id="more-10792"></span><br />
Grazie的功能是什么？例如下图，你在字符串里写了一句话&#8220;<span style="color:#0000ff;">This are an simple ...</span>&#8221;&#160;显然这里的 <span style="color:#ff0000;">are</span>&#160;是有语法错误的，应该是 <span style="color:#ff0000;">is</span>，此时Grazie就会提示有错：<br />
<img decoding="async" alt="intellij grazie plugin" src="https://www.codelast.com/wp-content/uploads/ckfinder/images/grazie_2.png" style="width: 700px; height: 368px;" /><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 />
从Grazie的简介看，使用它的时候会针对设置的language，下载对应的模型到本地使用。因此，Grazie应该也是基于机器学习技术的插件。<br />
这个功能虽然很好，但我认为，在当前的编程环境下，这个插件没有现实意义。</p>
<p>举个例子来说，像语法超级严格的Golang，不允许左花括号另起一行，如果你这么写就会被判定为语法错误。这样的限制，让很多开发者没办法随心所欲地按自己的喜好来写代码，同时也在一定程度上保证了大家的代码规范统一。但是，对某些没有被定义成&#8220;语法错误&#8221;，仅仅是影响&#8220;观感&#8221;的问题，Golang就不管了，比如 <span style="color:#ff0000;">func main() {</span>，你把 <font color="#ff0000">)</font>&#160;和&#160;<span style="color:#ff0000;">{&#160;</span>之间的空格去掉，也是能编译过的，只不过这种不规范，会让人很不爽而已。<br />
所以Go推出了 gofmt&#160;这个代码格式化工具，来让代码统一到完全一致的风格，但是如果团队里没有人使用它的话，这玩意有个鬼用？除非把它整合在持续集成的系统里，<span style="color:#0000ff;">当开发者提交代码的时候，不100%符合规范的代码，直接报错，不允许提交到代码库</span>，否则 gofmt&#160;就只能是个虚的角色。靠自觉？太不现实了。<br />
我之前短暂地开发过一段时间的Golang程序，讲真心话，就算在Golang这么严格的语法要求下，team里的其他人还是各种不遵守规范(那些可以通过编译的&#8220;不规范&#8221;)，并且还是把代码提交到了repo里，真让人无语。<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 />
再拿规范超级不严格的Python来说，那问题就更多了。什么结尾没有newline，各种换行不对齐之类的的问题，根本就不会被判定为语法问题，现在随便去GitHub上看很多知名library的代码都会发现这样的情况，这些问题在开发者中都已经普遍得不得了了，根本没有多少Python开发者关心。所以，连这些问题都不关心的开发者们，还能要求他们去关注自然语言里的语法错误那些&#8220;微不足道&#8221;的破事吗？我觉得根本不现实。<br />
在PyCharm里格式化Python代码使之符合PEP8编码规范，只是按一个快捷键就能做到的事，就这么简单，很多人都不愿意去做，所以，如果上了Grazie的&#8220;紧箍咒&#8221;，岂不要了大家的命了？所以，还是算了吧...<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 />
最后，有追求的人请安装Grazie，就算学学英文语法也是不错的：<br />
<img decoding="async" alt="intellij Grazie plugin" src="https://www.codelast.com/wp-content/uploads/ckfinder/images/grazie_1.png" style="width: 700px; height: 403px;" /></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>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij%e6%8e%a8%e5%87%ba%e7%9a%84%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5%e6%8f%92%e4%bb%b6grazie%ef%bc%8c%e6%b2%a1%e6%9c%89%e7%8e%b0%e5%ae%9e%e6%84%8f%e4%b9%89/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
今天看到一篇推送的技术文章，说IntelliJ推出了一个语法检查插件<a href="https://blog.jetbrains.com/idea/2019/11/meet-grazie-the-ultimate-spelling-grammar-and-style-checker-for-intellij-idea/" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">Grazie</span></a>，但它不是用于检查面向编译器的语法，而是用于检查面向人类的语法，比如引号里的字符串、注释语句里的语法，等等。我认为在当前的环境下，它没有意义&mdash;&mdash;除非在一个有着严格要求(或者非常自律)的团队里，否则这种功能只能用来&ldquo;折腾自己&rdquo;，而不可能改善大家整体的代码状况。<br />
<span id="more-10792"></span><br />
Grazie的功能是什么？例如下图，你在字符串里写了一句话&ldquo;<span style="color:#0000ff;">This are an simple ...</span>&rdquo;&nbsp;显然这里的 <span style="color:#ff0000;">are</span>&nbsp;是有语法错误的，应该是 <span style="color:#ff0000;">is</span>，此时Grazie就会提示有错：<br />
<img decoding="async" alt="intellij grazie plugin" src="https://www.codelast.com/wp-content/uploads/ckfinder/images/grazie_2.png" style="width: 700px; height: 368px;" /><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 />
从Grazie的简介看，使用它的时候会针对设置的language，下载对应的模型到本地使用。因此，Grazie应该也是基于机器学习技术的插件。<br />
这个功能虽然很好，但我认为，在当前的编程环境下，这个插件没有现实意义。</p>
<p>举个例子来说，像语法超级严格的Golang，不允许左花括号另起一行，如果你这么写就会被判定为语法错误。这样的限制，让很多开发者没办法随心所欲地按自己的喜好来写代码，同时也在一定程度上保证了大家的代码规范统一。但是，对某些没有被定义成&ldquo;语法错误&rdquo;，仅仅是影响&ldquo;观感&rdquo;的问题，Golang就不管了，比如 <span style="color:#ff0000;">func main() {</span>，你把 <font color="#ff0000">)</font>&nbsp;和&nbsp;<span style="color:#ff0000;">{&nbsp;</span>之间的空格去掉，也是能编译过的，只不过这种不规范，会让人很不爽而已。<br />
所以Go推出了 gofmt&nbsp;这个代码格式化工具，来让代码统一到完全一致的风格，但是如果团队里没有人使用它的话，这玩意有个鬼用？除非把它整合在持续集成的系统里，<span style="color:#0000ff;">当开发者提交代码的时候，不100%符合规范的代码，直接报错，不允许提交到代码库</span>，否则 gofmt&nbsp;就只能是个虚的角色。靠自觉？太不现实了。<br />
我之前短暂地开发过一段时间的Golang程序，讲真心话，就算在Golang这么严格的语法要求下，team里的其他人还是各种不遵守规范(那些可以通过编译的&ldquo;不规范&rdquo;)，并且还是把代码提交到了repo里，真让人无语。<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 />
再拿规范超级不严格的Python来说，那问题就更多了。什么结尾没有newline，各种换行不对齐之类的的问题，根本就不会被判定为语法问题，现在随便去GitHub上看很多知名library的代码都会发现这样的情况，这些问题在开发者中都已经普遍得不得了了，根本没有多少Python开发者关心。所以，连这些问题都不关心的开发者们，还能要求他们去关注自然语言里的语法错误那些&ldquo;微不足道&rdquo;的破事吗？我觉得根本不现实。<br />
在PyCharm里格式化Python代码使之符合PEP8编码规范，只是按一个快捷键就能做到的事，就这么简单，很多人都不愿意去做，所以，如果上了Grazie的&ldquo;紧箍咒&rdquo;，岂不要了大家的命了？所以，还是算了吧...<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 />
最后，有追求的人请安装Grazie，就算学学英文语法也是不错的：<br />
<img decoding="async" alt="intellij Grazie plugin" src="https://www.codelast.com/wp-content/uploads/ckfinder/images/grazie_1.png" style="width: 700px; height: 403px;" /></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-intellij%e6%8e%a8%e5%87%ba%e7%9a%84%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5%e6%8f%92%e4%bb%b6grazie%ef%bc%8c%e6%b2%a1%e6%9c%89%e7%8e%b0%e5%ae%9e%e6%84%8f%e4%b9%89/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创]如何添加一个文件/目录到IntelliJ项目的classpath中</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 03 Mar 2013 13:10:40 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[classpath]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[添加到classpath]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=5744</guid>

					<description><![CDATA[<p>
以下内容的背景：IntelliJ，Java项目。<br />
在单元测试中，我们经常会使用与生产环境里不同的一些配置文件来为提供参数，而你的程序又是以类似下面的方法来读取配置文件：</p>
<pre class="brush:java;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
String configFileName = &#34;config.properties&#34;;
Properties properties = new Properties();
properties.load(MyClass.class.getClassLoader().getResourceAsStream(configFileName));
</pre>
<p>上面的代码中仅使用了配置文件名，而不是其完整路径，这就导致了可能在IntelliJ中运行一个单独的单元测试的时候，找不到该配置文件，因为你只提供文件名的话，该文件必须要在classpath中，否则是找不到它的。<br />
<span id="more-5744"></span><br />
所以，我们可以把该配置文件所在的目录添加到IntelliJ项目里的classpath中，让它可以在运行单元测试的时候找得到。方法如下（一图胜千言，直接看下面的演示图就明白了）：<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 />
点击菜单File&#8594;Project Structure，进入&#8220;Project Structure&#8221;对话框，点击左侧的&#8220;Modules&#8221;，然后点击中部的&#8220;Dependencies&#8221;tab，然后再点击右部的&#8220;+&#8221;号添加你指定的目录，这里要注意了，在弹出的&#8220;Attach Files&#8221;对话框中，你必须要选择&#8220;classes&#8221;（如图所示）。最后，把目录添加进来之后，再把它们对应的&#8220;Scope&#8221;设置为&#8220;Test&#8221;，表示在测试中会依赖这个目录，即可。<br />
<img decoding="async" alt="add a file or directory to the classpath of an IntelliJ Java project" src="http://www.codelast.com/wp-content/uploads/2013/03/project_structure_with_demo_final.png" style="width: 576px; height: 218px; " /><br />
<strong><span style="color:#ff0000;">图片可保存下来放大查看。</span></strong></p>
<p>以上方法在IntelliJ 12.0.4中亲测通过，对于其他版本的IntelliJ也应该类似。</p>
<p><span style="background-color:#00ff00;">【补充】</span><br />
12.1.4版的IntelliJ与上面的图略有不同。在点击了&#8220;+&#8221;号之后，会弹出一个菜单：</p>
<div style="text-align: center;">
	<img decoding="async" alt="add menu" src="http://www.codelast.com/wp-content/uploads/2013/03/add_menu.png" style="width: 158px; height: 89px;" /></div>
<p>选择&#8220;Jars or directories...&#8221;，然后会弹出对话框让你选择目录或文件，选择好之后，和上面一样，要选择&#8220;classes&#8221;，后面的操作也一样了。</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>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<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>&#160;<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>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']</script>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
以下内容的背景：IntelliJ，Java项目。<br />
在单元测试中，我们经常会使用与生产环境里不同的一些配置文件来为提供参数，而你的程序又是以类似下面的方法来读取配置文件：</p>
<pre class="brush:java;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
String configFileName = &quot;config.properties&quot;;
Properties properties = new Properties();
properties.load(MyClass.class.getClassLoader().getResourceAsStream(configFileName));
</pre>
<p>上面的代码中仅使用了配置文件名，而不是其完整路径，这就导致了可能在IntelliJ中运行一个单独的单元测试的时候，找不到该配置文件，因为你只提供文件名的话，该文件必须要在classpath中，否则是找不到它的。<br />
<span id="more-5744"></span><br />
所以，我们可以把该配置文件所在的目录添加到IntelliJ项目里的classpath中，让它可以在运行单元测试的时候找得到。方法如下（一图胜千言，直接看下面的演示图就明白了）：<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 />
点击菜单File&rarr;Project Structure，进入&ldquo;Project Structure&rdquo;对话框，点击左侧的&ldquo;Modules&rdquo;，然后点击中部的&ldquo;Dependencies&rdquo;tab，然后再点击右部的&ldquo;+&rdquo;号添加你指定的目录，这里要注意了，在弹出的&ldquo;Attach Files&rdquo;对话框中，你必须要选择&ldquo;classes&rdquo;（如图所示）。最后，把目录添加进来之后，再把它们对应的&ldquo;Scope&rdquo;设置为&ldquo;Test&rdquo;，表示在测试中会依赖这个目录，即可。<br />
<img decoding="async" alt="add a file or directory to the classpath of an IntelliJ Java project" src="http://www.codelast.com/wp-content/uploads/2013/03/project_structure_with_demo_final.png" style="width: 576px; height: 218px; " /><br />
<strong><span style="color:#ff0000;">图片可保存下来放大查看。</span></strong></p>
<p>以上方法在IntelliJ 12.0.4中亲测通过，对于其他版本的IntelliJ也应该类似。</p>
<p><span style="background-color:#00ff00;">【补充】</span><br />
12.1.4版的IntelliJ与上面的图略有不同。在点击了&ldquo;+&rdquo;号之后，会弹出一个菜单：</p>
<div style="text-align: center;">
	<img decoding="async" alt="add menu" src="http://www.codelast.com/wp-content/uploads/2013/03/add_menu.png" style="width: 158px; height: 89px;" /></div>
<p>选择&ldquo;Jars or directories...&rdquo;，然后会弹出对话框让你选择目录或文件，选择好之后，和上面一样，要选择&ldquo;classes&rdquo;，后面的操作也一样了。</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>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
