当前位置:文档之家› Eclipse配置规范

Eclipse配置规范

1. Eclipse配置规范1.1. 工具1.PMD检查无用的代码和重复的代码2.CheckStyle检查代码、注释样式3.FindBugs检查代码缺陷4.JavaNCss java代码测量,计算有效代码行数5.JDepend检查各个包中间的依赖6.Maven3。

0.37.Eclipse3.6。

28.Mylyn1.2. 工具使用及配置1.2.1.JDK配置1.卸载本地已经安装的所有JDK2.下载安装SUN JDK 6 最新版本3.安装完毕后在我的电脑图标上点击鼠标右键,选择属性 > 高级〉环境变量点击界面最下方的新建按钮,输入变量名为JAVA_HOME变量值为JDK安装目录根目录,点击确定保存,再点确定,直到退出系统属性设置4.进入eclipse菜单: Window > Preferences 〉 Java 〉 Installed JRES,点击界面右上方的Add在弹出框中选择Standard VM,点击Next,点击 JRE home:右侧的 Directory,选择JDK安装路径,点确定点击界面下方的Finish,回到Installed JREs界面勾上刚才安装的JDK,点击界面右下方的OK1.2.2.Maven配置1.Window 〉 Preferences〉Maven去掉所有勾选项2.Window > Preferences〉Maven〉Installations〉Add,选择本地Maven Home目录,注意项目组统一Maven版本为3.0。

33.Window > Preferences〉Maven>User Settings〉Browse,选择C:\Documents and Settings\Administra tor\.m2\settings。

xml文件,如果目录下不存在此文件,找项目负责人要。

4.如果需要在运行中使用maven命令,需要配置Maven环境变量。

1.2.3.Workspace配置1.进入eclipse菜单:Window > Preferences > General 〉 Workspace > Local History2.勾选Limit history size,并将其下的三个选项都设置的尽量大,以便能保存更多的本地历史记录,避免丢失修改1.2.4.编码配置1.进入eclipse菜单: Window 〉 Preferences 〉 General 〉 Workspace2.找到Text file encoding3.点选Other4.在Other右边的下拉框中,选择UTF—85.点击界面右下角的Apply6.进入Window 〉 Preferences 〉 Web 〉 CSS Files7.选择Encoding为 ISO 10646/Unicode(UTF-8)8.点击界面右下角的Apply9.进入Window 〉 Preferences > Web 〉 HTML Files10.选择Encoding为 ISO 10646/Unicode(UTF-8)11.勾上Use workspace encoding12.点击界面右下角的Apply13.进入Window > Preferences 〉 Web 〉 JSP Files14.选择Encoding为 ISO 10646/Unicode(UTF—8)15.点击界面右下角的Apply16.进入eclipse菜单: Window 〉 Preferences > General > Editors 〉 Text Editors 〉 Spelling 17.修改Encoding,改为UTF-8,点击界面右下角的Apply18.点击右下角的OK,退出Preferences1.2.5.部署配置1.Window〉show view>Server>Servers2.右键>New〉Server〉Tomcat v6.0 Server〉选择本地tomcat6 home path>finish3.双击配置好的 Server Locations〉选中Use custom location…〉修改Server path为。

tomcat4.点击Timeouts设置Start为90,Stop为45,当不够时可以再次修改5.配置CATLINA_HOME环境变量,值为你配置好的tomcat根目录,注意不要\后缀,如我的则为E:\workspace\isoftstone\wk_everbright\。

tomcat1.2.6.Code Setting配置在配置之前先将eclipse目录下comment_template.xml文件中@author后面的名字改成自己的名字1.进入eclipse菜单: Window 〉 Preferences > Java > Code Style 〉 Clean Up2.点击界面上方的Import3.在弹出框中选择位于eclipse安装路径下的eclipse/cleanup—profile。

xml,点击打开4.点击右下角的 Apply 使其生效5.进入eclipse菜单: Window > Preferences 〉 Java 〉 Code Style 〉 Formatter6.使用类似上述的方法导入eclipse/formatter-profile。

xml,并使其生效7.进入eclipse菜单: Window > Preferences 〉 Java > Editor > Save Actions8.勾选上Perform the selected actions on save 下的Format source code,并选择 Format all lines 9.勾选上Organize imports,点击右下角的 Apply 使其生效10.进入eclipse菜单: Window > Preferences 〉Java〉Code Style〉Code Templates〉Import 11.选择eclipse安装路径下的comment_template。

xml,点击右下角Apply生效12.进入eclipse菜单: Window > Preferences > XML > XML Files 〉 Editor13.将Line width改为一个更大的值,因为宽屏能显示更大的范围,建议值为12014.点击右下角的 Apply 使其生效15.进入eclipse菜单: Window 〉 Preferences 〉 General 〉 Editors > Text Editors16.勾选上 Show line numbers ,点击右下角的 Apply 使其生效。

这样就可以看到代码的行号17.进入eclipse菜单: Window > Preferences > General 〉 Editors 〉 Text Editors 〉 Spelling 18.如果不想IDE进行拼写检查,可以取消Enable spell checking;也可以将Options下的某些忽略检查规则取消,使检查更严格19.点击右下角的 Apply 使其生效1.2.7.CheckStyle配置1.进入eclipse菜单: Window 〉 Preferences > Checkstyle2.勾选上右侧界面中General Settings下的“Include rule names"和“Include module id”3.点击界面右侧的New4.在弹出框的Type中,选择 Remote Configuration5.在输入框Name中录入:ebiz (注意必须录入此name,不建议使用其他name以免同步SVN时报错)(未完)6.在Location中录入http://:17000/isoftstone/spec/ebiz_checkstyle。

xml 7.勾选界面左下角的Cache configuration file,点击OK8.在界面的Global Check Configurations中选择刚添加的一行,使之高亮9.点击界面右侧的Set as Default按钮10.点击界面右侧的Configure按钮11.在弹出界面的左侧菜单中点选JavaDoc Comments > Type Javadoc12.在右侧的框中点中Style Javadoc,点下方的Open,在弹出界面中去掉checkFirstSentence的勾(如果已去掉,则忽略此步骤)13.在左侧菜单中点选Size Violations,在右侧的框中点中Maximum Parameters,点下方的Open,在弹出界面中修改max为30(如果已经为30,则忽略此步骤)14.点击界面下方的OK,退出15.要在项目中生效,必须首先点选项目,然后右键菜单中选择Properties16.在弹出界面左侧点选Checkstyle,右侧勾上Checkstyle active for this project和Use simple configuration17.在Simple—use the following check configurantion for all files的下拉框中选择上述导入的checkstype文件名ebiz18.点击界面下方的OK20.1.2.8.PMD配置1.进入eclipse菜单: Window > Preferences > PMD2.修改右侧界面中的Maximum reported violations per file per rule的值为303.进出菜单:Window 〉 Preferences 〉 PMD > Rules Configuration4.点击右侧 Clear all 删除全部 Rule5.选择 Import rule set,选择文件[附件: PMD.xml],选择 Import by Reference(未完)6.点击界面右下方的Apply,弹出提示全部选择Yes。

之后将会导致rebuild所有项目,如果因此出现Error,则进行一次全部项目的clean7.要在项目中生效,必须首先点选项目,然后右键菜单中选择Properties8.在弹出界面左侧点选PMD,右侧勾上Enable PMD即可9.点击界面下方的OK补充:第4、5步操作对PMD Rule的具体修改内容如下,供参考:1.修改Naming Rules的MethodNamingConventions,将Priority改为Information2.修改Naming Rules的ShortVariable,将Priority改为Information3.修改Naming Rules的LongVariable,将Priority改为Information4.修改Controversial Rules的 AtLeastOneConstructor,将Priority改为Information5.修改Controversial Rules的 OnlyOneReturn,将Priority改为Information6.修改Optimization Rules的 MethodArgumentCouldBeFinal,将Priority改为Information7.修改Java Logging Rules的LoggerIsNotStaticFinalRule,将Priority改为Information8.修改JUnit Rules的TestClassWithoutTestCase,将Priority改为Information9.修改Controversial Rules的NullAssignment,将Priority改为Information10.修改Design Rules的NonStaticInitializer,将Priority改为Information11.修改Design Rules的UseSingleton,将Priority改为Information12.修改Braces Rules的IfStmtsMustUseBraces,将Priority改为Information13.修改所有Migration Rules JUnit4的Priority改为Information14.选中Code Size Rules的TooManyFields,在界面下部的Rules properties中将Rule properties 中的maxfields改为3015.选中Code Size Rules的ExcessiveParameterList,在界面下部的Rules properties中将Rule properties中的minimum改为3016.修改Security Code Guidelines的MethodReturnsInternalArray,将Priority改为Information 17.修改Security Code Guidelines的ArrayIsStoredDirectly,将Priority改为Information1.2.9.JBoss配置(未完)1.安装JBOSS2.进入eclipse菜单: Window 〉 Preferences 〉 Server > Runtime Enviroments3.点击界面右上方的Add4.在弹出框中点开JBoss,选择JBoss v5.0,点击Next5.JRE一栏,选择已经安装的JDK6;Application Server Directory一栏则选择JBOSS的安装路径(例如:E:\jboss—5.1。

相关主题