文章列表

Maven导入项目中常遇到的坑

作者:じ☆ve宝贝

> maven项目导入的时候经常会遇到一些问题,接下来从下面几个点帮助大家调整一下 #### 1.ClassNotFoundException 这个错误大家经常会出现,但是在maven中我的pom.xml中明明已经出现了,为什么还是会提示这个错误呢?请打击查看一下打出的war包或者部署在tomcat路径下的项目中lib包又没有pom中的jar包,肯定时空的(废话要不怎么会出现ClassNotFoundException)。 解决方案: ``` 右键项目——>Deployment Assembly——>properties——>Deployment Assembly——>Add——>Java Build Path Entries——>Maven Dependencies——>Ok ``` 大功告成,这样tomcat肯定就不会出现类似错误 #### 2.导入tomcat中出现一些很奇怪的错误 例如:提示类不能实例化或者提示了一些其他项目的错误 解决方案: ``` 1.确保eclipse中仅加载了当前一个项目 2.Project——>Clean... 3.删除tomcat目录work\Catalina\中的全部内容(或者删除当前tomcat重新解压一个tomcat,以为之前项目的一些缓存导致该问题) ``` #### 3.Cannot change version of project facet Dynamic web module to 2.5 ``` 1.找到项目目录,打开项目中的 .setting文件夹 2.编辑org.eclipse.wst.common.project.facet.core.xml 3.修改 <installed facet="jst.web" version="3.0"/>为<installed facet="jst.web" version="2.5"/> 4.刷新eclipse中的项目或者clean一下就好了 ```

聊一聊开发常用小工具

作者:微信小助手

<section class="output_wrapper" 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;background-image: linear-gradient(90deg, rgba(50, 0, 0, 0.047) 3%, rgba(0, 0, 0, 0) 3%), linear-gradient(360deg, rgba(50, 0, 0, 0.047) 3%, rgba(0, 0, 0, 0) 3%);background-size: 20px 20px;background-position: 50% 50%;"> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">今天参加了公司的第一次线下培训,感觉很不错,内心也是越来越期待以后去公司的生活了。我想你和我一样都很清楚一些不错的小工具在开发中可以为我们节省很多时间,希望肥朝老哥总结的一些开发常用小工具能对你有帮助,这些工具都是这位老哥经常用到的!另外再推荐一篇文章:<a href="https://mp.weixin.qq.com/s?__biz=MzU4NDQ4MzU5OA==&amp;mid=2247484905&amp;idx=1&amp;sn=4bc0d4b72ef50efd075d827fe5bff1cd&amp;chksm=fd985388caefda9e175c8ebb95d941f40ca9ff225f49cf58e982af0170ba3ec7f99da84168a7&amp;token=1515347623&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2">如何提高自己的自学效率</a></p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><span style="color: inherit;font-size: inherit;letter-spacing: 0px;">之前不少朋友问到平时怎么学习的.今天就简单介绍一下平时用到的一些小工具.首先我平时是用</span><code style="font-size: inherit;letter-spacing: 0px;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">IDEA</code><span style="color: inherit;font-size: inherit;letter-spacing: 0px;">开发的,所以下面的介绍都是和</span><code style="font-size: inherit;letter-spacing: 0px;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">IDEA</code><span style="color: inherit;font-size: inherit;letter-spacing: 0px;">相关的.本文主要介绍我平时在哪些场景使用,使用了哪些功能,至于IDEA怎么安装插件和插件有哪些额外的功能,</span><strong style="color: inherit;font-size: inherit;letter-spacing: 0px;line-height: inherit;">这些你把插件名字对着搜索引擎一搜就很多了.</strong><br></p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0252100840336134" data-s="300,640" src="/upload/51e95ceeabd2c9ef533d051e1246068a.png" data-type="png" data-w="238" style=""></p> </figure> <h2 style="color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;font-size: 1.4em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">1.SequenceDiagram</span></h2> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这个工具是能根据代码生成时序图的.我们直接看效果</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.9511111111111111" data-s="300,640" src="/upload/5ccc64ddc17682cf25f30cdc51015bf7.png" data-type="png" data-w="1350" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">对着源码中的方法,就能自动生成时序图,这个在分析源码的时候非常有用,并且双击时序图中的色块还能直接跳转进源码的位置.喜欢看源码的朋友可以试试</p> <h2 style="color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;font-size: 1.4em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">2.PlantUML</span></h2> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这个是画时序图的工具.画时序图的工具有很多,那为什么要用这个呢?它究竟解决了什么问题?</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.3472222222222222" data-s="300,640" src="/upload/4e9c770e7a5c6ff248972ddb84758279.png" data-type="png" data-w="1584" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这个工具是用<code style="font-size: inherit;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">Markdown</code>语法来画图的.移植性就很好.</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">假如你是通过某个平台,或者某个软件画图的,那么你拿到源文件要修改就没这么好修改,因为可能这个画图工具要收费,可能这个画图软件是Mac系统才有,Window没有,你就很不方便导入源文件修改之前同事的时序图.用这个工具则不同了,画图的同事上传时序图后,把Markdown一贴,如下</p> <pre style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 0px;margin-bottom: 0px;padding: 0px;"><code class="hljs vbscript" style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;padding: 0.5em;background: rgb(0, 0, 0);color: rgb(248, 248, 248);display: block !important;overflow-wrap: normal !important;word-break: normal !important;overflow: auto !important;"><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">1</span>@startuml<br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">2</span>Alice&nbsp;-&gt;&nbsp;Bob:&nbsp;Authentication&nbsp;<span class="hljs-built_in" style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;">Request</span><br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">3</span>Bob&nbsp;--&gt;&nbsp;Alice:&nbsp;Authentication&nbsp;<span class="hljs-built_in" style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;">Response</span><br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">4</span><br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">5</span>Alice&nbsp;-&gt;&nbsp;Bob:&nbsp;Another&nbsp;authentication&nbsp;<span class="hljs-built_in" style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;">Request</span><br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">6</span>Alice&nbsp;&lt;--&nbsp;Bob:&nbsp;another&nbsp;authentication&nbsp;<span class="hljs-built_in" style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;">Response</span><br><span class="linenum hljs-number" style="font-size: inherit;line-height: inherit;color: rgb(255, 115, 253);padding-right: 20px;overflow-wrap: inherit !important;word-break: inherit !important;">7</span>@enduml<br></code></pre> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">你只要找到能支持<code style="font-size: inherit;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">Markdown</code>时序图语法的工具,都能把图片生成出来.</p> <h2 style="color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;font-size: 1.4em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">3.掘金-Chrome插件</span></h2> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">看优秀的源码,才能不断精进,但是关键是,我不知项目的源码.那么这个插件或许能帮到你</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.605427974947808" data-s="300,640" src="/upload/ce24f7be3d721b505558577d9aaf807d.png" data-type="png" data-w="2874" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">左边是文章,右边是最大的同性交友网站.比如阿里前几天开源的分布式事务框架在首页</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">有了这个插件,最热门的开源技术尽收眼底,时刻保持对技术的敏锐性</p> <h2 style="color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;font-size: 1.4em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">4.Maven Helper</span></h2> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这个是我在公司要求必装的一个插件,另外我在评审代码评审的第一步就是检查项目的依赖冲突,如果我们用idea自带的依赖分析工具,那么出现如下情况</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.7382617382617382" data-s="300,640" src="/upload/bcb0b14777b68af94817a0590c5d09a6.png" data-type="png" data-w="2002" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">坦白说,你让我在这么庞大的一幅图中,分析依赖,找出依赖冲突,坦白说,我认为不够直观.那么用上这个插件之后呢?</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.7126546146527117" data-s="300,640" src="/upload/bc9cf69271e64e916d80bb7c08d5c35c.png" data-type="png" data-w="2102" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">红色的就是出现依赖冲突,例如图中的<code style="font-size: inherit;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">commons-logging</code>,点击进入我画框框的地方,他就会从依赖路径上给你分析依赖冲突的路径.其实这个的原因也很简单,就是利用Maven的依赖树命令</p> <h2 style="color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;font-size: 1.4em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">5.RestfulToolkit</span></h2> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">平时<code style="font-size: inherit;line-height: inherit;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">Controller</code>方法太多,找起来太费劲?这个插件来帮你</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.2631578947368421" data-s="300,640" src="/upload/1a1228579e88d243a7c2b8f67242f045.png" data-type="png" data-w="874" style=""></p> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">只要输入url路径,立刻跳转到指定方法,节省效率不止一点点</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><br></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: normal;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(0, 82, 255);font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">推荐阅读</strong></span></p> <ul class=" list-paddingleft-2" style=""> <li><h4 style="margin-top: 1.5rem;margin-bottom: 1rem;font-size: 18px;max-width: 100%;box-sizing: border-box;letter-spacing: 0.544px;color: rgb(21, 153, 87);text-align: start;line-height: normal;word-wrap: break-word !important;font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, Consolas, Inconsolata, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Courier New&quot;, &quot;Droid Sans Mono&quot;, &quot;Hiragino Sans GB&quot;, 微软雅黑, monospace !important;"><span style="max-width: 100%;font-size: 16px;box-sizing: border-box !important;word-wrap: break-word !important;">Redis</span></h4></li> </ul> <ul class=" list-paddingleft-2" style="list-style-type: square;"> <ul class=" list-paddingleft-2" style=""> <li><p style="max-width: 100%;min-height: 1em;line-height: normal;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="https://mp.weixin.qq.com/s?__biz=MzU4NDQ4MzU5OA==&amp;mid=2247484450&amp;idx=1&amp;sn=7ee03fa67aecd05c5becd2a8259d3631&amp;chksm=fd985243caefdb554ebab9149e750ac0c819074c57bd208f2d7f097fbc461ed58223e71c05f1&amp;token=1398134989&amp;lang=zh_CN&amp;scene=21#wechat_redirect" data-linktype="2" style="color: rgb(0, 82, 255);text-decoration: underline;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;word-break: break-all !important;"><span style="max-width: 100%;box-sizing: border-box;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);line-height: 22px;font-size: 16px;word-wrap: break-word !important;word-break: break-all !important;">redis 总结—</span><span style="max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;">—重构版</span></a></p></li> <li><p style="max-width: 100%;min-height: 1em;line-height: normal;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="https://mp.weixin.qq.com/s?__biz=MzU4NDQ4MzU5OA==&amp;mid=2247484478&amp;idx=1&amp;sn=a1250d9b8025cd7cb6fc6a58238ab51e&amp;chksm=fd98525fcaefdb499a027df0138c98d4b02d828f27bd6144a4d40a1c088d340c29dd53d4a026&amp;token=1398134989&amp;lang=zh_CN&amp;scene=21#wechat_redirect" data-linktype="2" style="color: rgb(0, 82, 255);text-decoration: underline;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;word-break: break-all !important;font-size: 14px !important;"><span style="max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;">史上最全Redis高可用技术解决方案大全</span></a><span style="max-width: 100%;box-sizing: border-box;color: rgb(74, 74, 74);line-height: 22px;word-wrap: break-word !important;font-size: 14px !important;">(非原创)</span></p></li> </ul> </ul> <ul class=" list-paddingleft-2" style=""> <li><h4 style="margin-top: 1.5rem;margin-bottom: 1rem;font-size: 18px;max-width: 100%;box-sizing: border-box;letter-spacing: 0.544px;color: rgb(21, 153, 87);text-align: start;line-height: normal;word-wrap: break-word !important;font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, Consolas, Inconsolata, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Courier New&quot;, &quot;Droid Sans Mono&quot;, &quot;Hiragino Sans GB&quot;, 微软雅黑, monospace !important;"><span style="max-width: 100%;font-size: 16px;box-sizing: border-box !important;word-wrap: break-word !important;">计算机网络</span></h4></li> </ul> <ul class=" list-paddingleft-2" style="list-style-type: square;"> <ul class=" list-paddingleft-2" style=""> <li><p style="max-width: 100%;min-height: 1em;line-height: normal;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="https://mp.weixin.qq.com/s?__biz=MzU4NDQ4MzU5OA==&amp;mid=2247484289&amp;idx=1&amp;sn=6b556843c60aac9a17b0e7c2e3cd6bca&amp;chksm=fd9855e0caefdcf6af4123b719448c81d90c5442d4052ae01a4698047e226c0c18c14b2cc54a&amp;token=1398134989&amp;lang=zh_CN&amp;scene=21#wechat_redirect" data-linktype="2" style="color: rgb(0, 82, 255);text-decoration: underline;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;word-break: break-all !important;font-size: 14px !important;"><span style="max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;">搞定计算机网络面试,看这篇就够了(补充版)</span></a></p></li> </ul> </ul> <ul class=" list-paddingleft-2" style=""> <li><h4 style="margin-top: 1.5rem;margin-bottom: 1rem;font-size: 18px;max-width: 100%;box-sizing: border-box;letter-spacing: 0.544px;color: rgb(21, 153, 87);text-align: start;line-height: normal;word-wrap: break-word !important;font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, Consolas, Inconsolata, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Courier New&quot;, &quot;Droid Sans Mono&quot;, &quot;Hiragino Sans GB&quot;, 微软雅黑, monospace !important;"><span style="max-width: 100%;font-size: 16px;box-sizing: border-box !important;word-wrap: break-word !important;">面试</span></h4></li> </ul> <ul class=" list-paddingleft-2" style="list-style-type: square;"> <ul class=" list-paddingleft-2" style=""> <li><h2 class="" style="max-width: 100%;line-height: normal;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="https://mp.weixin.qq.com/s?__biz=MzU4NDQ4MzU5OA==&amp;mid=2247484897&amp;idx=1&amp;sn=f37c4ae77436b41f38aeeb6d2537bad7&amp;chksm=fd985380caefda96898d6d3bb1a87aa81cdc54489a31a826c7dcecaa2b7763440d524e7a81bc&amp;token=1400384597&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="color: rgb(0, 82, 255);text-decoration: underline;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;font-size: 14px !important;"><span style="max-width: 100%;box-sizing: border-box;line-height: 22px;word-wrap: break-word !important;">2018年BATJ面试题精选</span></a></h2></li> </ul> <p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> </ul> <blockquote style="margin-top: 1em;margin-bottom: 1em;padding: 15px 15px 15px 1rem;max-width: 100%;box-sizing: border-box;word-wrap: normal;border-left-width: 6px;border-left-color: rgb(220, 230, 240);letter-spacing: 0.544px;white-space: normal;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: left;color: rgb(129, 145, 152);font-size: 0.9em;line-height: inherit;background: rgb(242, 247, 251);overflow: auto;word-break: normal;"> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;font-size: inherit;color: inherit;line-height: 2em;word-wrap: break-word !important;">专注Java知识分享!开源 Java 学习指南——JavaGuide(20k+ Star)的作者。<span style="max-width: 100%;font-size: 15.3px;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;">公众号多篇文章被各大技术社区转载。欢迎关注!</span></p> </blockquote> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);color: rgb(62, 62, 62);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 14px;text-align: left;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <figure style="max-width: 100%;box-sizing: border-box;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);color: rgb(62, 62, 62);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 16px;text-align: left;line-height: inherit;word-wrap: break-word !important;"> <img class="" data-ratio="1" data-type="jpeg" data-w="258" title="我的公众号" width="258px" src="/upload/cbd716d5fdc5e6264bbdc979a33185e7.jpg" style="margin-right: auto;margin-left: auto;box-sizing: border-box;border-width: 2px;border-style: solid;border-color: rgb(238, 238, 238);border-radius: 6px;font-size: inherit;color: inherit;line-height: inherit;display: block;word-wrap: break-word !important;visibility: visible !important;width: 175px !important;"> </figure> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);color: rgb(62, 62, 62);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 14px;text-align: left;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);color: rgb(62, 62, 62);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 14px;text-align: left;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(255, 0, 0);letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;">如果喜欢本文的话,小伙伴们不要忘记给本文点个好看以及转发分享。</span></p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><br></p> </section>

JDK8保留参数原本名称

作者:じ☆ve宝贝

在JDK8之前,java编译器会忽略我们编写代码时候设定的参数名,比如在mybatis框架中,我们可以使用@Param注解来让mybatis知道参数名。 ``` public interface DemoMapper { List<Card> getCardList(@Param("cardIds") List<Integer> cardIds); Card getCard(@Param("cardId")int cardId); } ``` 很长一段时间里,Java程序员一直在发明不同的方式使得方法参数的名字能保留在Java字节码中,并且能够在运行时获取它们(比如Paranamer类库)。最终,在Java 8中把这个强烈要求的功能添加到语言层面(通过反射API与Parameter.getName()方法)与字节码文件(通过新版的javac的–parameters选项)中。 ``` public class ParameterNames { public static void main(String[] args) throws Exception { Method method = ParameterNames.class.getMethod( "main", String[].class ); for( final Parameter parameter: method.getParameters() ) { System.out.println("isNamePresent: " + parameter.isNamePresent()); System.out.println( "Parameter: " + parameter.getName() ); } } } ``` 如果不使用–parameters参数来编译这个类,然后运行这个类,会得到下面的输出: ``` isNamePresent: false Parameter: arg0 ``` 如果使用–parameters参数来编译这个类,参数的真实名字将会显示出来: ``` isNamePresent: true Parameter: args ``` 如果是maven项目,可以配置maven编译插件: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <compilerArgument>-parameters</compilerArgument> <encoding>UTF-8</encoding> <source>1.8</source> <target>1.8</target> </configuration> </plugin> ``` java编译 ``` javac -parameters ***.java, ``` eclipse配置 ![](/upload/25cd8dacd4ff433f8e1a601aa9b2da1b.png) idea配置 ![](/upload/2e342da0e7f741948fb55f690d23cacb.png) Build,Execution,Deployment->Java Compiler 在框内填写-parameters参数 ![](/upload/6937cd5285e94dcab0804184f1f207cf.png)

[haddop]org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed

作者:じ☆ve宝贝

``` 2016-07-11 03:36:12,570 INFO org.apache.hadoop.hdfs.server.common.Storage: Lock on /data/hadoop/dfs/data/in_use.lock acquired by nodename 5846@localhost.localdomain 2016-07-11 03:36:12,573 WARN org.apache.hadoop.hdfs.server.common.Storage: java.io.IOException: Incompatible clusterIDs in /data/hadoop/dfs/data: namenode clusterID = CID-74ab72a1-21f6-46f8-8eb1-107b11aeb3a4; datanode clusterID = CID-13c79279-c9ab-4d18-bd00-7c1a74137112 2016-07-11 03:36:12,579 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool <registering> (Datanode Uuid unassigned) service to /192.168.159.128:19000. Exiting. java.io.IOException: All specified directories are failed to load. ``` 从日志上看是因为 datanode的clusterID 和 namenode的clusterID 不匹配。 解决方法: 根据日志中的路径/data/hadoop/tmp/dfs,master可以看到name目录,salve可以看到data目录, 将name/current下的VERSION中的clusterID复制到data/current下的VERSION中,覆盖掉原来的clusterID,目的是让两个保持一致。 然后重启,就可以看到slave上的DataNode进程已经起来。 出现该问题的原因:在第一次格式化dfs后,启动并使用了hadoop,后来又重新执行了格式化命令(hdfs namenode -format),这时namenode的clusterID会重新生成,而datanode的clusterID 保持不变。

网站热度统计PV/并发

作者:不要哭啦

**PV计算带宽**;有了PV才可算计算带宽 假设网站的平均日PV:10w 的访问量页面平均大小0.4 M 网站带宽 = 10w /(24 \* 60 \* 60)求出每秒多少PV/S PV/S \* 0.4M \* 8 =多少kb最后换算3.7 Mbps **具体的计算公式是:网站带宽= PV / 统计时间(换算到S)\*平均页面大小(单位KB)\* 8** 在实际的网站运行过程中,我们的网站必须要在峰值流量时保持正常的访问,假设,峰值流量是平均流量的5倍,按照这个计算,实际需要的带宽大约在 3.7 Mbps \* 5=18.5 Mbps 字节的单位是Byte,而带宽的单位是bit,1Byte=8bit,所以转换为带宽的时候,要乘以 8 **PV与并发** **具体的计算公式是:并发连接数 = PV / 统计时间 \* 页面衍生连接次数 \* http响应时间 \* 因数 / web服务器数量** 页面衍生连接次数: 一个页面请求会有好几次http连接如外部的css, js,图片等,这个根据实际情况而定 http响应时间: 平均一个http请求的响应时间可以使用1秒或更少。 因数: 峰值流量 和平均流量的倍数,一般使用5 ,最好根据实际情况计算后得出。 10万PV的并发连接数: (100000PV / 86400秒 \* 50个派生连接数 \* 1秒内响应 \* 5倍峰值) / 1台Web服务器 = 289 并发连接数 单台服务器的并发/进程数=QPS(单进程单位时间接受的成功请求数)不是最大并发量; QPS = 总请求数 / ( 进程总数 \* 请求时间 ) pv还可以这样算qps\*进程数\*每天秒杀/用户停留时间?????有了PV才可算qps 服务器数量 = ( 每天总PV / 单台服务器每天总PV ); 原理:每天80%的访问集中在20%的时间里,这20%时间叫做峰值时间 公式:( 总PV数 \* 80% ) / ( 每天秒数 \* 20% ) = 峰值时间每秒请求数(QPS) 机器:峰值时间每秒QPS / 单台机器的QPS = 需要的机器 例子:每天300w PV 的在单台机器上,这台机器需要多少QPS? ( 3000000 \* 0.8 ) / (86400 \*0.2 ) = 139 (QPS) 例子:如果一台机器的QPS是58,需要几台机器来支持? 139 / 58 = 3

Ubuntu Linux iptables配置说明

作者:じ☆ve宝贝

### 1.查看当前规则 ``` iptables -L ``` ### 2.开放80端口 ``` iptables -A INPUT -p tcp -i eth0 --dport 80 -j ACCEPT ``` ### 3.禁止所有请求、只允许通过的端口 ``` iptables -A INPUT -j DROP ``` ### 4.保存 ``` iptables-save > /etc/iptables.up.rules ``` ### 5.设置网络启动时自动应用防火墙 ``` vi /etc/network/interfaces pre-up iptables-restore < /etc/iptables.up.rules ``` ### 6.以行的形式查看规则 ``` sudo iptables -nvL --line-numbers ``` ### 7.删除第6条的规则 ``` sudo iptables -D INPUT 6 ``` ### 8.启动防火墙 ``` iptables-apply /etc/iptables.up.rules ``` ### 9.关闭防火墙(依次执行) ``` sudo iptables -P INPUT ACCEPT sudo iptables -P OUTPUT ACCEPT sudo iptables -P FORWARD ACCEPT sudo iptables -F ``` 编写脚本 ``` echo "Stopping firewall and allowing everyone..." iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT ``` ### 10.随网卡自动启动 vi /etc/network/interfaces 找到auto eth0 ``` iface eth0 inet dhcp ``` #### 在后面加上 ``` pre-up iptables-restore < /etc/iptables.rules #开启应用规则 post-down iptables-restore < /etc/iptables.downrules post-down iptables-save < /etc/iptables.up.rules #关闭时自动保存 ``` 官方文档:https://help.ubuntu.com/community/IptablesHowTo

sqlyog64位 mysql数据库可视化工具v12.0.9

作者:じ☆ve宝贝

序 列 号(Code):8d8120df-a5c3-4989-8f47-5afc79c56e7c 序 列 号(Code):59adfdfe-bcb0-4762-8267-d7fccf16beda 序 列 号(Code):ec38d297-0543-4679-b098-4baadf91f983

html 本站微粒子背景特效源码

作者:じ☆ve宝贝

``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>particle nets</title> <style> html,body{ margin: 0; padding: 0; height: 100%; overflow: hidden;} </style> </head> <body> <canvas id="cas"></canvas> <script> var canvas = document.getElementById("cas"); var ctx = canvas.getContext("2d"); resize(); window.onresize = resize; function resize(){ canvas.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; canvas.height = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight)-200; } var RAF = (function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); }; })(); // 鼠标活动时,获取鼠标坐标 var warea = {x: null, y: null, max: 20000}; window.onmousemove = function(e){ e = e || window.event; warea.x = e.clientX; warea.y = e.clientY; }; window.onmouseout = function(e){ warea.x = null; warea.y = null; }; // 添加粒子 // x,y为粒子坐标,xa, ya为粒子xy轴加速度,max为连线的最大距离 var dots = []; for(var i=0;i<300;i++){ var x = Math.random()*canvas.width; var y = Math.random()*canvas.height; var xa = Math.random() * 2 - 1; var ya = Math.random() * 2 - 1; dots.push({ x: x, y: y, xa: xa, ya: ya, max: 6000 }) } // 延迟100秒开始执行动画,如果立即执行有时位置计算会出错 setTimeout(function(){ animate(); }, 100); // 每一帧循环的逻辑 function animate(){ ctx.clearRect(0,0,canvas.width, canvas.height); // 将鼠标坐标添加进去,产生一个用于比对距离的点数组 var ndots = [warea].concat(dots); dots.forEach(function(dot){ // 粒子位移 dot.x += dot.xa; dot.y += dot.ya; // 遇到边界将加速度反向 dot.xa *= (dot.x > canvas.width || dot.x < 0)? -1 : 1; dot.ya *= (dot.y > canvas.height || dot.y < 0)? -1 : 1; // 绘制点 ctx.fillRect(dot.x - 0.5, dot.y - 0.5, 1, 1); // 循环比对粒子间的距离 for (var i = 0; i < ndots.length; i++) { var d2 = ndots[i]; if (dot === d2 || d2.x === null || d2.y === null) continue; var xc = dot.x - d2.x; var yc = dot.y - d2.y; // 两个粒子之间的距离 var dis = xc * xc + yc * yc; // 距离比 var ratio; // 如果两个粒子之间的距离小于粒子对象的max值,则在两个粒子间画线 if(dis < d2.max){ // 如果是鼠标,则让粒子向鼠标的位置移动 if (d2 === warea && dis > (d2.max / 2)) { dot.x -= xc * 0.03; dot.y -= yc * 0.03; } // 计算距离比 ratio = (d2.max - dis) / d2.max; // 画线 ctx.beginPath(); ctx.lineWidth = ratio/2; ctx.strokeStyle = 'rgba(0,0,0,' + (ratio + 0.2) + ')'; ctx.moveTo(dot.x , dot.y); ctx.lineTo(d2.x , d2.y); ctx.stroke(); } } // 将已经计算过的粒子从数组中删除 ndots.splice(ndots.indexOf(dot), 1); }); RAF(animate); } </script> </body> </html> ```

MySQL 大表优化方案

作者:微信小助手

<blockquote style="max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;line-height: 25.6px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;overflow-wrap: break-word !important;"> <p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;">来源:manong</span></p> <p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;">segmentfault.com/a/1190000006158186</span></p> </blockquote> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">当MySQL单表记录数过大时,增删改查性能都会急剧下降,可以参考以下步骤来优化:</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <h3 style="max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(171, 25, 66);font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">单表优化</strong></span></h3> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">除非单表数据未来会一直不断上涨,否则不要一开始就考虑拆分,拆分会带来逻辑、部署、运维的各种复杂度,一般以整型值为主的表在千万级以下,字符串为主的表在五百万以下是没有太大问题的。而事实上很多时候MySQL单表的性能依然有不少优化空间,甚至能正常支撑千万级以上的数据量:</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <h4 style="font-size: medium;max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">字段</strong></span></h4> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"></p> <ul class=" list-paddingleft-2" style=""> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">尽量使用TINYINT、SMALLINT、MEDIUM_INT作为整数类型而非INT,如果非负则加上UNSIGNED</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">VARCHAR的长度只分配真正需要的空间</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">使用枚举或整数代替字符串类型</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">尽量使用TIMESTAMP而非DATETIME,</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">单表不要有太多字段,建议在20以内</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">避免使用NULL字段,很难查询优化且占用额外索引空间</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">用整型来存IP</span></p></li> </ul> <h4 style="font-size: medium;max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></h4> <h4 style="font-size: medium;max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">索引</strong></span></h4> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 16px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"></p> <ul class=" list-paddingleft-2" style=""> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">索引并不是越多越好,要根据查询有针对性的创建,考虑在WHERE和ORDER BY命令上涉及的列建立索引,可根据EXPLAIN来查看是否用了索引还是全表扫描</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">应尽量避免在WHERE子句中对字段进行NULL值判断,否则将导致引擎放弃使用索引而进行全表扫描</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">值分布很稀少的字段不适合建索引,例如”性别”这种只有两三个值的字段</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">字符字段只建前缀索引</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">字符字段最好不要做主键</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">不用外键,由程序保证约束</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">尽量不用UNIQUE,由程序保证约束</span></p><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p></li> <li><p style="max-width: 100%;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;word-wrap: break-word !important;">使用多列索引时主意顺序和查询条件保持一致,同时删除不必要的单列索引</span></p></li> </ul> <h4 style="font-size: medium;max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255,

Eclipse 代码格式化

作者:じ☆ve宝贝

## Google的代码风格 1、下载eclipse-java-google-style.xml ``` https://github.com/google/styleguide ``` 2、 导入方法: ``` Eclipse->window->preferences-> Java->Code Style->Formatter->Import 选择eclipse-java-google-style.xml文件 ``` 点击apply,ok就行了。 3、这样就可以选中代码进行格式化(默认快捷键是Ctrl+Shift+F),用以保持代码风格一致。 ``` //默认的缩进是2格,一般习惯都是四格的缩进,可以在edit里面修改一下 indentation size 4;Tab size 4; ``` ## eclipse 默认设置的换行长度 ##### 打开Eclipse的Window菜单,然后 1.Java代码 ``` Preferences->Java->Code Style->Formatter->Edit ->Line Wrapping->Maximum line width:默认80加个0,改成800就行了。 ``` 2.CSS代码 ``` Window->Preferences->Web->CSS Files->Editor->Line width:默认为72加个0,改为720保存。 ``` 3.Html代码 ``` Window->Preferences->Web->HTML Files->Editor->Line width:默认为72加个0,改为720保存。 ``` 4.JSP代码 ``` Window->Preferences->Web->JSP Files->Editor->Line width:默认为72加个0,改为720保存。 ```