一、下載
地址:官網下載地址
二、安裝
運行安裝程序,一路下一步。注意選擇安裝路徑。
三、基本概念
project:相當於donet中的解決方案(solution),eclipse中的工作空間(workspace)
module:相當於donet中的項目工程(project),eclipse中的項目(project)
四、IDE界面介紹
JAVA IDE IntelliJ IDEA使用簡介(一)—之界面元素
JAVA IDE IntelliJ IDEA使用簡介(二)—之基本操作
JAVA IDE IntelliJ IDEA使用簡介(三)—之你不能忘記的快捷鍵
顯示與隱藏常用窗口,IDE左下角的正方形按鈕,如下圖:
五、基本設置
字號設置:File->Settings->Editor->Color&Fonts->Fonts
顯示行號設置:File->Settings->Editor->General->Appearence->Show line numbers
背景色設置:File->Settings->Editor->Color&Fonts->General->Default text->Background
默認編碼設置:File----->Other Settings----->Default Setting------>Editor----->FileEncodings
全局設置
1、file-》close project
2、configure
六、創建maven項目
6.1 新建項目,選擇項目類型,JDK,以及maven項目模板,如下圖:
6.2 設置項目GroupId(組織標識),ArtifactId(項目名稱),Version(版本號)
6.3 設置maven安裝路徑,配置文件路徑,本地倉庫路徑
6.4 設置項目名稱,及項目路徑
6.5 新建項目成功后的項目結構
注意事項:
Module 下的 SDK 和 language level
項目----->右鍵----->Open Module Settings 打開Project Structure窗口設置即可。
全局Maven配置文件路徑及Maven倉庫地址配置
File->Settings->Build->Maven
七、集成jetty
7.1 在pom.xml文件中加入以下配置
<build> <finalName>com.www.demo.webapp</finalName> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.1.v20140609</version> </plugin> </plugins> </build>
如果需要運行jsp程序,則需要依賴相應的jar包
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
7.2 成功后maven窗口如下,右鍵jetty:run即可
在瀏覽器中輸入http://localhost:8080顯示如下界面,則表明運行成功
maven項目文件結構說明
.idea目錄下是存放項目的配置信息,包括歷史記錄,版本控制信息等;
src目錄下是開發資源;
target目錄下是輸出內容;
main目錄里是項目的主要代碼和資源;
test目錄里是用於測試的代碼和資源,在測試周期會被使用,而打包的時候不會被包含
java目錄顧名思義放java相關的源代碼;
resource目錄則放一些非代碼的資源文件,例如配置文件、媒體文件等,這個目錄下的文件在構建時不會被進行編譯之類的額外處理,只會原樣復制到輸出目錄;
iml是 intellij idea的工程配置文件,里面是當前projec的一些配置信息。
八、maven項目原型(archetype)說明
1: internal -> appfuse-basic-jsf (創建一個基於Hibernate,Spring和JSF的Web應用程序的原型) 2: internal -> appfuse-basic-spring (創建一個基於Hibernate,Spring和Spring MVC的Web應用程序的原型) 3: internal -> appfuse-basic-struts (創建一個基於Hibernate,Spring和Struts 2的Web應用程序的原型) 4: internal -> appfuse-basic-tapestry (創建一個基於Hibernate, Spring 和 Tapestry 4的Web應用程序的原型) 5: internal -> appfuse-core (創建一個基於 Hibernate and Spring 和 XFire的jar應用程序的原型) 6: internal -> appfuse-modular-jsf (創建一個基於 Hibernate,Spring和JSF的模塊化應用原型) 7: internal -> appfuse-modular-spring (創建一個基於 Hibernate, Spring 和 Spring MVC 的模塊化應用原型) 8: internal -> appfuse-modular-struts (創建一個基於 Hibernate, Spring 和 Struts 2 的模塊化應用原型) 9: internal -> appfuse-modular-tapestry (創建一個基於 Hibernate, Spring 和 Tapestry 4 的模塊化應用原型) 10: internal -> maven-archetype-j2ee-simple (一個簡單的J2EE的Java應用程序) 11: internal -> maven-archetype-marmalade-mojo (一個Maven的 插件開發項目 using marmalade) 12: internal -> maven-archetype-mojo (一個Maven的Java插件開發項目) 13: internal -> maven-archetype-portlet (一個簡單的portlet應用程序) 14: internal -> maven-archetype-profiles () 15: internal -> maven-archetype-quickstart () 16: internal -> maven-archetype-site-simple (簡單的網站生成項目) 17: internal -> maven-archetype-site (更復雜的網站項目) 18: internal -> maven-archetype-webapp (一個簡單的Java Web應用程序) 19: internal -> jini-service-archetype (Archetype for Jini service project creation) 20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype) 21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (無殘留) 原型) 22: internal -> softeu-archetype-jsf (JSF+Facelets 原型) 23: internal -> jpa-maven-archetype (JPA 應用程序) 24: internal -> spring-osgi-bundle-archetype (Spring-OSGi 原型) 25: internal -> confluence-plugin-archetype (Atlassian 聚合插件原型) 26: internal -> jira-plugin-archetype (Atlassian JIRA 插件原型) 27: internal -> maven-archetype-har (Hibernate 存檔) 28: internal -> maven-archetype-sar (JBoss 服務存檔) 29: internal -> wicket-archetype-quickstart (一個簡單的Apache Wicket的項目) 30: internal -> scala-archetype-simple (一個簡單的scala的項目) 31: internal -> lift-archetype-blank (一個 blank/empty liftweb 項目) 32: internal -> lift-archetype-basic (基本(liftweb)項目) 33: internal -> cocoon-22-archetype-block-plain ([http://cocoapacorg2/maven-plugins/]) 34: internal -> cocoon-22-archetype-block ([http://cocoapacorg2/maven-plugins/]) 35: internal -> cocoon-22-archetype-webapp ([http://cocoapacorg2/maven-plugins/]) 36: internal -> myfaces-archetype-helloworld (使用MyFaces的一個簡單的原型) 37: internal -> myfaces-archetype-helloworld-facelets (一個使用MyFaces和Facelets的簡單原型) 38: internal -> myfaces-archetype-trinidad (一個使用MyFaces和Trinidad的簡單原型) 39: internal -> myfaces-archetype-jsfcomponents (一種使用MyFaces創建定制JSF組件的簡單的原型) 40: internal -> gmaven-archetype-basic (Groovy的基本原型) 41: internal -> gmaven-archetype-mojo (Groovy mojo 原型)
九、項目導入與項目依賴
通過pom文件導入項目:Maven Projects->加號->選擇對應項目的pom文件,成功后在項目視圖下展示。相當於donet中的添加現有項目。
其他導入:
十、配置TypeScript開發環境
1、安裝nodeJs
2、安裝並升級typescript版本
npm install -g typescript
3、配置
typescript包路徑:C:\Users\用戶名\AppData\Roaming\npm\node_modules\typescript\lib
十一、常用插件
Lombok Plugin
Google Protocal Buffers Support
設置protoc.exe路徑:Build,Execution,Deployment=> Compiler Protocol Buffers Compiler 指定插件地址
十二、導入外部工具
十三、IDEA中git的使用
IntelliJ-IDEA和Git、GitHub、Gitlab的使用(五)
十四、快捷鍵
F9 resume programe 恢復程序
Alt+F10 show execution point 顯示執行斷點
F8 Step Over 相當於eclipse的f6 跳到下一步
F7 Step Into 相當於eclipse的f5就是 進入到代碼
Alt+shift+F7 Force Step Into 這個是強制進入代碼
Shift+F8 Step Out 相當於eclipse的f8跳到下一個斷點,也相當於eclipse的f7跳出函數
Atl+F9 Run To Cursor 運行到光標處
ctrl+shift+F9 debug運行java類
ctrl+shift+F10 正常運行java類
alt+F8 debug時選中查看值
ctrl+g 定位到某一行
ctrl+q 注釋放大查看
==============================================================
格式化代碼:
idea編輯器本身是自動格式化代碼呀,如果要手動,只需要快捷鍵Ctrl+Alt+L或者選擇文件再選擇reformat code
==============================================================
類和方法的注釋:
創建類和方法的時候按/**,然后回車就可以把自己設置的顯示出來
十五、技巧
intellij idea 如何將一個普通項目轉換為maven項目
1、工程文件下新建文件pom.xml,並填寫好內容。
2、在pom.xml 文件上右鍵 Add as Maven Project。
intellij idea 如何在同一窗口中打開多個項目
1、open -》文件夾 -》加載項目
2、在編輯器左下角打開菜單,選中 Maven Projects
3、在編輯器右側的 Maven Projects窗口中,選擇窗口工具條中的 + (加號)添加pom.xml文件
idea通過git導入java項目
菜單-》File-》New-》Project from version control -》 Git
idea生成代碼時序圖
進入擴展程序安裝 File > Settings > Plugins > Browse Repositories
搜索 SequenceDiagram,點擊右邊 Install 安裝,然后重啟 IDEA 。
參考文檔
圖文介紹IntelliJ IDEA 創建基於Maven構建的Web項目
Intellij IDEA 的使用(創建項目、導入項目、同時部署多個項目、JRebel)等常見eclipse、myeclipse換idea必看
eclipse與intellij idea中的classpath分析
Intellij IDEA 14.x 中的Facets和Artifacts的區別
Intellij IDEA的Facets和Artifacts
intellij idea 13&14 插件推薦及快速上手建議 (已更新!)
Tomcat部署時war和war exploded區別以及平時踩得坑