天天看点

IJ整理

本文介绍的是绿色版安装,安装之前请参考Selecting the JDK version the IDE will run under和zip安装包下面的Install-Windows-zip.txt

一.下载最新版ideaIU-14.1.3.zip并解压到你想要安装的目录.下载完最好验证一下sha256

至于下载地址:

如果想得到稳定的发行版:到https://www.jetbrains.com/idea/download/点击Download Ultimate,发觉下载的是exe,只要将下载地址的exe改为zip(到了IDEA15.0.1+应改为win.zip)就行.

如果想得到早期访问预览版(EAP):https://confluence.jetbrains.com/display/IDEADEV/EAP,下一步就看你了.

二.配置JDK.通过以上的参考,我配置64位的方法:复制64位jdk1.8到安装目录,并重命名为jre64.

实际上除了jre目录,lib目录和lib目录下面的tools.jar,这个jre64的其它目录与文件都可以删除

三.注册.双击bin\idea64.exe来运行.输入以下Licence

User or company name:

xiejx618

License key:

84293-Y5CGU-1W8NJ-CDDM3-QAN66-VCQP5

至于licence怎么得到,可以参考http://www.rover12421.com/2014/11/18/jetbrains-keggen.html

四.根据自己偏好配置插件

1.插件配置:

Java Frameworks:J2EE,Hibernate,Spring

Build Tools:Maven,Gradle

Web Development:HTML,CSS,LESS,JavaScript

Version Controls:Disable

Test Tools:JUnit

Application Servers:Disable

Clouds:Disable

Swing:Disable

Android:Enable

Database Tool:Enable

Other Tools:Bytecode Viewer

Plugin Development:Disable

2.设置配置.

a.file encodings:ide encoding和project encoding,properties files都设为utf-8,勾上Transparent native-to-ascii conversion

b.maven,svn,git设置.maven设置maven home directory;svn设置svn命令路径,svn配置目录;git命令路径;

c..show line:勾上show line numbers和show whitespaces

d.updates:设为不更新.

e.去掉reopen last project on startup的勾

idea的属性文件UTF-8编码详细设置

输入中文,通过Resource Bundle Editor自动将文字转为Unicode编码.

1.ctrl+alt+s打开Setting,File Encoding->Default encoding for properties file设为UTF-8,勾上右边的Transparent native-to-ascii conversion

IJ整理

2.通过Resource Bundle Editor打开某个属性文件,输入文字,这时编辑器会自动透明帮你转换.值得提醒的是:在Resource Bundle Editor看不到转化效果(也就是你输入中文,Resource Bundle Editor还是显示中文,实际上文件已经做了转换,通过记事本打开看就知道了)

IJ整理
IJ整理
IJ整理

经常用到的快捷键:

Alt+F7 Find Usages

Shift+F6 Rename

Ctrl+A Select All

Ctrl+B Declaration

Ctrl+C Copy

Ctrl+E Recent Files

Ctrl+G Go To Line

Ctrl+N Go To Class

Ctrl+O Override Methods

Ctrl+P Parameter Info

Ctrl+Q Quick Documentation

Ctrl+U Super Method

Ctrl+V Paste

Ctrl+W Extend Select

Ctrl+/ Comment

Ctrl+Shift+F Find In Path

Ctrl+Shift+N Go To File

Ctrl+Shift+T Go To Test

Ctrl+Alt+L Reformat Code

Ctrl+Atl+O Optimize Import

Ctrl+Alt+T Surround With

Ctrl+Alt+V Extract Variable

Ctrl+Shift+向左箭头 Back

Ctrl+Shift+向右箭头 Foward

Ctrl+Shift+向上箭头 Up

Ctrl+Shift+向下箭头 Down

Ctrl+Alt+Shift+F7 Open Find Usages Dialog

常见问题:
maven多模块项目时,在子模块运行的Working Directory问题.运行java应用方法Working Directory被默认设为项目的根目录而不是模块的根目录.
比如在
project-parent
    +-module1
        +- src
            +-main
                +-java
                    +-org
                        +-exam
                            \-Test.java
        \-text.txt
        \-pom.xml
    \-pom.xml

Test.java
package org.exam;
import java.io.File;
public class Test {
    public static void main(String[] args) {
        System.out.println("result = " + new File("test.txt").exists());
    }
}
引用:http://stackoverflow.com/questions/5637765/how-to-deal-with-relative-path-in-junits-between-maven-and-intellij
解决办法:In Run->Edit configuration->Defaults->JUnit->Working directory set the value $MODULE_DIR$ and Intellij will set the relative path in all junits just like Maven.
在对应的运行配置设置Working directory为$MODULE_DIR$,运行上面的测试,发现相对路径就会正确