====== IntelliJ IDEA Config 설정 ====== * [[:intellij_idea|IntelliJ IDEA]] 설정. * [[http://beyondj2ee.wordpress.com/2013/06/01/%ec%9d%b8%ed%85%94%eb%a6%acj-%ec%8b%9c%ec%9e%91%ed%95%98%ea%b8%b0-part1-getting-start-intellij-%ea%b8%b0%eb%b3%b8-%ec%84%a4%ec%a0%95%ed%8e%b8/|인텔리J 시작하기 Part1 (Getting Start IntelliJ) -기본 설정편]] * [[intellij_idea:shortcut|IntelliJ IDEA Shortcut 단축키]] * [[https://www.jetbrains.com/help/idea/sharing-your-ide-settings.html|Sharing Your IDE Settings - Help | IntelliJ IDEA]] IDEA 설정 동기화 방법 ===== JDK 선택 ===== * 2016.3 혹은 그 이전 버전부터 ''Ctrl+Shift+A'' 에서 ''Switch IDE boot JDK''에서 JDK를 지정할 수 있다. -- 구버전 -- * [[https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under|Selecting the JDK version the IDE will run under]] IntelliJ 를 실행할 JDK 지정하기 * 보통은 ''IDEA_JDK'' 환경변수를 설정해주면된다. * Windows ''idea64.exe''는 ''IDEA_JDK_64''를 읽는다. ===== VMOptions ===== * [[https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties|Configuring JVM options and platform properties – IDEs Support (IntelliJ Platform) | JetBrains]] * 기본적으로는 **Help -> Edit Custom VM Options** 메뉴에 나오는 파일에서 JVM Option 조정 * ''${IDEA_HOME}/bin'' 에 보면 ''idea.exe.vmoptions/idea.vmoptions''와 ''idea64.exe.vmoptions/idea64.vmoptions'' 두 파일이 32bit/64bit에 따라 IntelliJ IDEA 실행 JVM 옵션을 주는 파일이다. * MS Windows의 경우 실행파일이 ''idea.exe''면 ''idea.exe.vmoptions''를 ''idea64.exe''이면 ''idea64.exe.vmoptions''를 실행한다. * Linux/Mac 계열은 32/64bit를 자동판단한다. * 자기 환경에 맞는 아키텍처의 설정파일을 수정해주면 된다. * [[https://dzone.com/articles/the-one-and-only-reason-to-customize-intellij-idea|The One and Only Reason to Customize IntelliJ IDEA Memory Settings]] : ''Xmx''를 최소 2gb로 세팅하자. * [[http://devnet.jetbrains.com/thread/312461|Intellij Idea JVM options benchmark]] Java 7에서는 G1 GC로 바꿔볼 것 -Xms2g -Xmx2g -XX:ReservedCodeCacheSize=240m -XX:+UseCompressedOops -XX:+UseG1GC ... 기타 옵션들 ... -Dawt.useSystemAAFontSettings=lcd * ''-server'' 옵션은 빼자. 시작 속도가 엄청 느려진다. * 한글로 된 HOME 디렉토리(특히 Windows에서) 사용시 Code Coverage가 작동하지 않는 등의 문제가 있다. ''vmoptions''에서 ''java.io.tmpdir''을 영어로 된 디렉토리로 바꿔줘야 한다. -Djava.io.tmpdir=C:\Temp ===== Linux 한글 입력 ===== * Linux 입력기 문제는 버전에 따른 편차가 매우 크기 때문에, **잘된다면 아래내용 무시할것.** * [[linux:inputmethod|Input Method (입력기, 한글)]]에서 한글 입력이 잘 안 될 경우 ==== fcitx ==== * [[linux:inputmethod:fcitx|Linux Input Method fcitx]] 한글 입력이 잘 안 될경우 [[https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006740379-2019-3-Update-disabled-Fcitx-input-Ubuntu|2019.3 Update disabled Fcitx input? - Ubuntu – IDEs Support (IntelliJ Platform) | JetBrains]] * ''-Dauto.disable.input.methods=false'' ==== ibus ==== * [[linux:inputmethod:ibus|iBus]] 한글 입력이 잘 안 될 경우 [[https://youtrack.jetbrains.com/issue/JBR-2444|Keyboard stops working in IntelliJ on Ubuntu 20.04, Gnome 3.36 with IBus enabled : JBR-2444]] * 즉시 해결 ibus-daemon -rd * ''Edit Custom VM Options...'' -Drecreate.x11.input.method=true * 한글 입력시 공백등이 튈 경우 gsettings set org.freedesktop.ibus.engine.hangul use-event-forwarding true ===== 설정 파일들의 디렉토리 변경 ===== * [[https://www.jetbrains.com/help/idea/tuning-the-ide.html#config-directory|설정 파일 디렉토리]] * 설정 파일 : ''~/.config/JetBrains/'' * 캐시와 local history 파일 : ''~/.cache/JetBrains/'' * 플러그인 : ''~/.local/share/JetBrains/'' * [[https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs|Directories used by the IDE to store settings, caches, plugins and logs]] * [[https://intellij-support.jetbrains.com/hc/en-us/articles/207240985-Changing-IDE-default-directories-used-for-config-plugins-and-caches-storage|Changing IDE default directories used for config, plugins, and caches storage]] * config: configuration (idea.config.path) * config\plugins: plugins (idea.plugins.path) * system: caches, local history, etc (idea.system.path) * system\log: logs and thread dumps (idea.log.path) ''idea.properties'' 커스텀 설정에서 아래 값들을 변경해준다. idea.config.path=/path/to/config idea.plugins.path=/path/to/config/plugins idea.system.path=/path/to/system idea.log.path=/path/to/log * Windows 에서 한글 사용자명 폴더일 경우에 config.path와 system.path를 변경시켜줘야한다. 안그러면 일부 기능이 작동하지 않을 수 있다. ===== Idea Properties ===== * 기본적으로는 **Help -> Edit Custom Properties** 메뉴에 나오는 파일에서 편집한다. * ''$IDEA_HOME/bin/idea.properties'' 파일에서 직접 편집하거나 내용을 가져다가 하나씩 바꾸면된다. ===== 성능 ===== * Java 7 사용시 메모리 2GB에 G1 GC를 사용하니까 성능이 안정적이었다. * 각 프로젝트별로 **Settings -> Inspections**에서 Spelling을 비롯한 불필요한 항목들을 제거해준다. * VisualVM + VisualGC 등으로 보면서 안정 상태 확인할 것. * Inspection 등의 옵션 바꾸고 성능 확인시 가능하면 껐다 켜 볼 것. 옵션 변경이 즉시 적용이 안되는 경우가 있는 것으로 느껴진다. * Windows Defender 혹은 그외 Anti Virus 백신에서 프로젝트 디렉토리를 제외 처리 해야 성능이 좋아진다. * [[https://www.jetbrains.com/help/idea/tuning-the-ide.html|Tuning IntelliJ IDEA - Help | IntelliJ IDEA]] ===== Console Buffer size ===== * **과도한 Console 로깅은 IntelliJ의 GC를 유발하며 성능을 현격히 떨어뜨린다.** 로깅양이 많을 경우 IntelliJ가 멈춘 것 처럼 보인다. * ''idea.properties'' 파일에서 * ''idea.cycle.buffer.size=1024'' 항목을 KB 단위로 변경. 나는 보통 ''10240''. ===== Linux 설정 ===== * [[http://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit|Inotify Watches Limit]] * inotify watch 설정값이 작으면 파일 변경사항 확인시 무한 루프 비슷한 상황에 빠질 수도 있다. * ''/etc/sysctl.conf''에 충분한 값으로 설정해주기 fs.inotify.max_user_watches = 524288 * 아래 명령으로 적용 후 IntelliJ 재시작 sudo sysctl -p ===== 자동 빌드 - auto build ===== * 자동 빌드는 클래스가 변경될 때마다 자동으로 컴파일하고, 배포한다. * 나는 자동 빌드 활성화 시에 **지나치게 잦은 compile & deploy로 인한 성능저하** 문제가 더 크다고 보고, 이를 꺼둔 상태로 사용한다.(IntelliJ Idea 자체도 기본값이 끄기) * Actions 에서 **Registry...** 를 찾아서 * ''compiler.automake.allow.when.app.running=true'' 로 변경 * **Settings -> Build, Execution, Deployment -> Compiler -> Build project automatically** 활성화. ===== Tomcat(WAS) 실행 옵션 ===== * Windows 환경에서 UTF-8 개발시 VMOptions에 ''-Dfile.encoding=UTF-8''을 지정하면 Tomcat등의 WAS 실행시에도 함께 ''-Dfile.encoding=UTF-8''옵션을 줘야한다. * 그렇지 않으면 IntelliJ IDEA 콘솔을 UTF-8로, Tomcat로그는 Windows 환경 인코딩(CP949)로 출력해서 한글 로그가 깨지게 된다. -Dfile.encoding=UTF-8 -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m ===== Settings ===== ==== Default Settings ==== * ''File -> New Project Settings'' 에서 모든 프로젝트의 기본 설정을 할 수 있다. * ''Annotation Processors -> Enable annotation processing'' : [[java:lombok|Lombok]] 사용시 항상 필요하므로 활성화 해 둔다. ==== Appearance ==== * ''Override default fonts by'' 에서 원하는 기본 글꼴 지정 * 테마 등을 변경할 수 있음. * ''Meterial Theme UI''를 설치하면 아이콘 등이 Meterial theme로 변경된다. * ''Show Memory Indicator'' : 메모리 현황을 보여준다. ==== 글꼴 / Font ==== * [[https://github.com/naver/d2codingfont|D2Coding]] ligature 를 사용하면 ''!='' 등의 코딩 기호를 간결하게 볼 수 있다. * **Enable ligature** check === Terminal Font === * **Settings -> Editor -> Color Scheme -> Console Font** 에서 명시할 수 있다. * ''CodeNewRoman Nerd Font Mono'' ==== System Settings ==== * ''Reopen last project on startup'' : 마지막으로 열었던 프로젝트를 시작시 다시 열기. (나는 꺼둠) ==== File Colors ==== * ''File Colors'' 메뉴에서 Test 파일, 프로젝트에 소속되지 않은 파일 등에 대한 배경 색을 지정할 수 있다. * 테마와 맞지않는 배경색으로 인해 파일이 잘 안보이는 경우가 있으므로 조정해야 하는 것이 좋다. ==== Editor -> Appearance ==== * ''Show line numbers'' 체크 * ''Show whitespaces'' 체크 * ''Show method separators'' 체크 : 메서드 단위로 박스가 쳐져서 보여짐 === 코드 Color Scheme === * [[https://github.com/jkaving/intellij-colors-solarized|IntelliJ Colors Solarized]] * [[https://github.com/whaley/ZenBurn-for-IntelliJ-Idea|ZenBurn for IntelliJ-IDEA]] * 적용 후, ''Editor -> Colors & Fonts -> Diif -> Conflict'' 에서 backgrount 를 ''#B40431''로 변경. * [[https://github.com/y3sh/Intellij-Colors-Sublime-Monokai|Sublime monokai]] === Coverage Miss 라인 표시 === * ''Editor -> Color Scheme -> General -> Line Coverage'' 에서 Partial과 Uncovered 에 **Background** 혹은 **Error stripe mark**를 준다. * Effects 는 잘 안먹는 것 같다. === Editor Tabs === * ''Mark modified tabs with asterisk'' 체크 : 수정된 파일에 * 표시 === Colors & Fonts -> File Status === * VCS 에서 파일이 추가/삭제/머지 등의 상태에 따른 색을 지정할 수 있다. * Darcula 테마 사용시 몇몇 컬러가 눈에 안 띄므로 변경해주는 것이 좋다. * **-> Diff** : Confliect : ''#0000FF'' 파란색 * [[http://www.jetbrains.com/idea/webhelp/file-status-highlights.html|File status highlights]] ==== Editor -> General -> Code Folding ==== * 코드가 너무 축약 돼 보인다. * ''One-line method'' 이하 ~ ''End of line comments sequence''까지 uncheck ==== Editor -> General ==== * ''Change font size (Zoom) with Ctrl+Mouse Wheel'' : 마우스 휠을 이용해 글꼴 크기 변경. ''Reset Font Size'' 액션으로 초기화 가능 * ''Editor Tabs''에서 ''Placement''를 ''None''으로 변경한다. 해보면 거의 사용안하고, ''Ctrl+E''로 최근 탭을 찾게 된다. * ''Render documentation comments'' : Javadoc HTML을 보기 좋게 변환해서 소스상에서 보여준다. * ''Surround selection on typing quote or brace'' : 텍스트를 선택하고 ''"'', ''%%'%%'', ''{}'' 를 입력하면 자동으로 감싸준다. * ''Soft Wraps'' * ''Soft-wrap these files'' : 지정된 확장자의 파일들을 soft wrap(긴줄을 아래로 내려서 보여주기)한다. ==== Code Formatter ==== * [[http://plugins.jetbrains.com/plugin/?id=6546|Eclipse Code Formatter]] 플로그인을 사용하여 Eclipse와 동일한 코드 포매터를 공유할 수 있다. -> 최근 버전에서는 IntelliJ 스스로 Eclipse Code Style을 import 할 수 있어서 불필요. * 설정의 ''Eclipse Code Formatter'' 항목에서 * ''Use the Eclipse code formatter''를 체크하고, * 원하는 Eclipse 포맷 파일 Export 한 것을 선택한다. * Java * Wrapping and Braces * ''Ensure right margin is not exceeded'' : "Right margin (cloumns)"를 넘어서는 줄을 포맷팅시 내려쓰기한다. * ''Kepp when reformatting'' * ''Line breaks'' : uncheck * Groovy * Wrapping and Braces * ''Use flying geese braces'' : closure { } 블록이 보기 좋게 맞게됨. * Chained method calls * ''Align when multiline'' ==== Encoding ==== * IDE Encoding, Project Encoding 을 현재 사용하는 "UTF-8"로 강제지정. * Properties도 UTF-8로 설정. * "Transparent native-to-ascii conversion"을 체크한다. 이걸 해주면 native-to-ascii 가 자동으로 수행된다. ==== Auto import ==== * **Add unambiguous imports on the fly** : 모호하지 않은 import 즉시 처리. * Lombok/Groovy 사용시 Annotation이 겹쳐서 혼란을 준다. 둘 중의 하나를 auto import에서 제외한다. **Exclude from import and Completion**에 다음 추가 groovy.transform.ToString groovy.transform.EqualsAndHashCode groovy.transform.Builder groovy.util.logging.Slf4j ==== Compiler ==== * ''Add runtime assertions for not-null-annotated method and parameters'' 옵션을 끄는게 좋다. ''@NonNull'' 혹은 ''@NotNull'' 등의 어노테이션이 붙은 코드에 null 값이 들어오면 에러내는 코드를 주입시켜서 혼란을 줄 수 있다. 다만, 로컬 환경에서 테스트시 필요하다 싶으면 켜도 좋다. ==== XFCE Descktop 사용시 ==== * ''설정 관리자 -> 창관리자 -> 키보드'' 에서 * [[linux:xfce|XFCE]] 참조 * **Alt-Insert**키 해제. * **Ctrl-FXX** 모두 해제. ===== Plugins ===== * ''Grep Console'' * [[https://github.com/gradle/gradle-intellij-gui/wiki|Gradle IntelliJ GUI]] * [[https://plugins.jetbrains.com/plugin/9567-request-mapper|request-mapper]] [[springframework:mvc|Spring MVC]] JAX-RS 등의 URL로 컨트롤러 클래스 검색 ==== Gradle ==== * 가능하면 ''Gradle Wrapper''사용, * **Auto Import**를 켜두면 ''build.gradle'' 변경시마다 자동으로 Refresh한다. 스크립트 변경이 잦을 경우에는 오히려 개발속도를 떨어뜨릴 수도 있다. * 웹 프로젝트의 경우 가끔 Gradle에서 **변경한 라이브러리 의존성이 갱신이 잘 안 되면 Artifact를 지우고 재생성**하면 즉시 갱신된다. ==== Lombok ==== * [[java:lombok|Lombok]] * **Settings -> Compiler -> Annotation Processors -> Enable annotation processing** 체크해야 사용가능. ===== Gradle ===== * [[:gradle|gradle]] 사용시 라이브러리 등이 변경되면 JetGradle에서 새로 고침을 해도 프로젝트 구조(Project Structure)에 반영이 안된다(12.x 버전 현재). * 이때 Project Structure에서 오류가 발생하게 되는데 여기서 Fix를 눌러 제거할 라이브러리를 제거하고, Artifacts에 추가할 라이브러리는 추가해주면된다. * **Libraries** 오류 먼저 잡고 그 뒤에 Artifacts 오류를 잡는게 나은 듯. ===== Clean IDEA ===== IntelliJ Idea 관련 프로젝트 설정 모두 삭제하기. 프로젝트 디렉토리에서 ''cleanIdea'' 실행. alias cleanIdea="find . -name '*.iml' -exec rm {} \;; rm -rf .idea" ===== Tomcat Server Log ===== * [[java:tomcat:log|Tomcat Log]]의 JULI 부분을 참조하여 톰캣 로그가 하나의 콘솔에 모두 찍히도록 한다. ===== Local Changes ===== * 원래 VCS Tool Window (''+9'') 에 **Local Changegs** 탭(Tasks 목록과 수정된 파일 목록을 보여줌)이 있어야 하는데 안보인다면 Action 에서 **Show Local Changes** 를 실행해본다. ===== Issue Navigation ===== * VCS 로그에 있는 커밋 메시지를 파싱하여 이슈 트래커로 가능 링크를 자동 생성해준다. * ''Settings -> Version Control -> IssueNavigation'' * [[https://www.jetbrains.com/idea/help/issue-navigation.html|IntelliJ IDEA 14.0.0 Web Help]] * Jira 예. commit 에 ''[XXX-123] 설명'' 형태로 적는다고 할 때 -> 최신 버전은 자동으로 **Add Jira pattern** 기능이 생겨서 불필요함. * Issue ID : ''\[([A-Z]+\-\d+)\].*'' * link : ''http://jira.url.com/browse/$1'' ===== Server certificate ===== * ''Server’s Certificate is not trusted'' 팝업이 지속적으로 뜰 경우(회사에서 개별 인증서 등록해서 사용시) 무조건 accept 하려면, * **Settings -> Tools -> Server Certificates** 에서 **Accept non-trusted certificates automatically** 를 활성화 해준다. ===== Windows WLS Linux Terminal & PowerShell ===== * ''Tools -> Terminal -> Shell Path'' 에서 경로를 ''C:\Windows\System32\bash.exe'' 로 잡아주면 자동으로 [[windows:wsl|Windows Subsystem For Linux]] 의 ''bash''를 터미널로 띄워준다. * ''C:\Users\\AppData\Local\Microsoft\WindowsApps\ubuntu.exe'' 도 가능한데, 이 경우 프로젝트 디렉토리를 실행디렉토리로 지정되지 않는다. * PowerShell 은 ''powershell.exe''로만 지정해도 된다. ===== 14.1.5 ===== * [[http://www.markhneedham.com/blog/2015/09/30/intellij-14-1-5-unable-to-import-maven-project/|IntelliJ 14.1.5: Unable to import maven project at Mark Needham]] * **Maven Importing VM 옵션에** ''-Didea.maven3.use.compat.resolver'' 추가