IDEA啟動之后卡頓
修改這兩個文件,內容如下:
-Xms1024m -Xmx4096m -XX:ReservedCodeCacheSize=1024m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+DisableExplicitGC -XX:SoftRefLRUPolicyMSPerMB=50 -Xverify:none -ea -XX:CICompilerCount=2 -Dsun.io.useCanonPrefixCache=false -Djava.net.preferIPv4Stack=true -Djdk.http.auth.tunneling.disabledSchemes="" -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Djdk.attach.allowAttachSelf=true -Dkotlinx.coroutines.debug=off -Djdk.module.illegalAccess.silent=true
復制類名包括包名在內的完整類名
顯示idea的工具欄:
Java JDK和IntelliJ IDEA 配置及安裝(好)
IDEA 超實用使用技巧分享(長篇)
設置創建類文件自動添加注釋
/** * <pre> * ${desc} * </pre> * @date ${DATE} ${TIME} * @author 你的名字 */
代碼提示不區分大小寫:
IDEA 實用功能Auto Import:自動優化導包(自動刪除、導入包)
Add unambiguous imports on the fly:快速添加明確的導入。
Optimize imports on the fly:快速優化導入,優化的意思即自動幫助刪除無用的導入。
設置 鼠標懸停 提示
idea 讀取配置文件出現亂碼解決辦法
注解生效激活:
File Type過濾:(設置IDEA項目隱藏那些文件或者文件夾)
統一設置idea父工程的包管理,spring cloud的pom.xml

1 <!-- 統一管理jar包版本 --> 2 <properties> 3 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 4 <maven.compiler.source>1.8</maven.compiler.source> 5 <maven.compiler.target>1.8</maven.compiler.target> 6 <junit.version>4.12</junit.version> 7 <log4j.version>1.2.17</log4j.version> 8 <lombok.version>1.16.18</lombok.version> 9 <mysql.version>5.1.47</mysql.version> 10 <druid.version>1.1.16</druid.version> 11 <mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version> 12 </properties> 13 14 <!-- 子模塊繼承之后,提供作用:鎖定版本+子modlue不用寫groupId和version --> 15 <dependencyManagement> 16 <dependencies> 17 <!--spring boot 2.2.2--> 18 <dependency> 19 <groupId>org.springframework.boot</groupId> 20 <artifactId>spring-boot-dependencies</artifactId> 21 <version>2.2.2.RELEASE</version> 22 <type>pom</type> 23 <scope>import</scope> 24 </dependency> 25 <!--spring cloud Hoxton.SR1--> 26 <dependency> 27 <groupId>org.springframework.cloud</groupId> 28 <artifactId>spring-cloud-dependencies</artifactId> 29 <version>Hoxton.SR1</version> 30 <type>pom</type> 31 <scope>import</scope> 32 </dependency> 33 <!--spring cloud alibaba 2.1.0.RELEASE--> 34 <dependency> 35 <groupId>com.alibaba.cloud</groupId> 36 <artifactId>spring-cloud-alibaba-dependencies</artifactId> 37 <version>2.1.0.RELEASE</version> 38 <type>pom</type> 39 <scope>import</scope> 40 </dependency> 41 <dependency> 42 <groupId>mysql</groupId> 43 <artifactId>mysql-connector-java</artifactId> 44 <version>${mysql.version}</version> 45 </dependency> 46 <dependency> 47 <groupId>com.alibaba</groupId> 48 <artifactId>druid</artifactId> 49 <version>${druid.version}</version> 50 </dependency> 51 <dependency> 52 <groupId>org.mybatis.spring.boot</groupId> 53 <artifactId>mybatis-spring-boot-starter</artifactId> 54 <version>${mybatis.spring.boot.version}</version> 55 </dependency> 56 <dependency> 57 <groupId>junit</groupId> 58 <artifactId>junit</artifactId> 59 <version>${junit.version}</version> 60 </dependency> 61 <dependency> 62 <groupId>log4j</groupId> 63 <artifactId>log4j</artifactId> 64 <version>${log4j.version}</version> 65 </dependency> 66 <dependency> 67 <groupId>org.projectlombok</groupId> 68 <artifactId>lombok</artifactId> 69 <version>${lombok.version}</version> 70 <optional>true</optional> 71 </dependency> 72 </dependencies> 73 </dependencyManagement> 74 75 <build> 76 <plugins> 77 <plugin> 78 <groupId>org.springframework.boot</groupId> 79 <artifactId>spring-boot-maven-plugin</artifactId> 80 <configuration> 81 <fork>true</fork> 82 <addResources>true</addResources> 83 </configuration> 84 </plugin> 85 </plugins> 86 </build> 87
設置新項目使用本地Maven
設置當前項目使用本地Maven
maven調試
idea 使用maven構建項目時,target bytecode version經常自動變化
解決方法:在工程的pom.xml中添加
<build>
<finalName>tb.easyuidemo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
或者 導入的項目需要設置java的版本
設置語言級別為Default
設置項目啟動使用代理方式連接網絡,中文亂碼:
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=1080 -Dfile.encoding=utf-8
設置SpringBoot啟動時使用環境變量:sharding
Program arguments: --spring.profiles.active=sharding
安裝常用插件
IDEA中debug程序的時候不想進入某些包或者類的解決方法
在IDEA偏好中(Preferences->Build,Execution,Deployment->Debugger->Stepping)設置Do not step into the classes選項,增加要過濾的包或者類:
IntelliJ IDEA 快捷鍵終極大全,速度收藏!
增加代碼提示快捷鍵:Ctrl+J(同VS提示代碼)
右鍵菜單:
彈出窗口,按Ctrl+J快捷鍵
點OK按鈕,選Leave,Remove刪除原來的。
增加格式化代碼快捷鍵:Ctrl+K,D(同VS提示代碼)
右鍵菜單Add keyboard Shortcut,設置組合快捷鍵
增加優化導入包快捷鍵:Ctrl+K,O
自定義重命名快捷鍵:F2
F2已經被占用了,無法使用,可以更換其他,默認是Shift+F6
常用的快捷鍵:
IDEA查看類型(接口)的所有實現類(快捷鍵:“ctrl + h” 或 接口類名左邊按鈕)
快速檢索類(快捷鍵:“ctrl + n” )
查看類結構(快捷鍵:“alt + 7” )
查看方法被使用的情況(快捷鍵:“alt + F7” )
查看最近使用的文件(快捷鍵:“ctrl + e” )
Ctrl+O 重寫父類方法
Ctrl+N 查找類,只能在父類或者接口上使用才能看到效果 Ctrl+Alt+O 優化導入的類和包,增加Ctrl+K,O
ALT+回車 導入包,自動修正
ALT+/ 代碼提示 ,增加Ctrl+J
Shift+F6 重構-重命名
CTRL+ALT+L 格式化代碼 ,增加Ctrl+K,D
CTRL+R 替換當前文件內容
CTRL+SHIFT+R 替換項目或者模塊文件內容
CTRL+F 查找當前文檔內容
CTRL+SHIFT+F 查找項目或者模塊文件內容
Shift+Shift 進入搜索框
CTRL+H 打開實現某個接口,繼承某個父類的所有子類型的窗口
CTRL+SHIFT+減號 折疊所有java代碼塊
CTRL+SHIFT+加號 展開所有java代碼塊
Shift+Shift:進入搜索框
Ctrl+H:打開實現某個接口或者繼承某個父類的所有子類型窗口
1.知道類名查找類:
CTRL+SHIFT+ALT+N
2.展示類下的所有方法和屬性
Ctrl+F12
(這個不一定是正確的,我現在用的不是社區的idea
的快捷鍵是Ctrl+F3
)
3. 快速查找類或方法在整個項目中的位置:
按住Ctrl
鍵再點擊類或方法會出現所有用到過的文件對象
CTRL + 滑動滾輪 調整窗口顯示大小
idea代碼編輯器tabs選項卡分多行顯示
idea設置代碼根據屏幕的大小自適應換行,一共三步
IDEA中輸出syso的快捷鍵設置
IDEA使用筆記(八)——自動生成 serialVersionUID 的設置
關閉 Intellij IDEA 的 Tab 頁(Intellij IDEA 一些不為人知的技巧)
- 直接用
Command + E
來找到最近訪問的文件:(Ctrl + E) - 或者直接用
Command + Shift + E
來訪問最近編輯的文件:(Ctrl + Shift + E)
How do you change highlighting for all files in IntelliJ?
設置項目熱啟動
設置代碼編輯器的默認字體和大小:JetBrainsMono
設置IDE字體:
安裝IDEA皮膚:Material Theme UI(深色系漂亮)
安裝IDEA皮膚:Gray Theme,Cyan Light Theme(我自己用這個皮膚),Espresso Light Theme(淺色系漂亮)
SpringBoot入門教程(一)詳解intellij idea搭建SpringBoot

1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-parent</artifactId> 8 <version>2.2.2.RELEASE</version> 9 <relativePath/> <!-- lookup parent from repository --> 10 </parent> 11 <groupId>com.example</groupId> 12 <artifactId>demo</artifactId> 13 <version>0.0.1-SNAPSHOT</version> 14 <name>demo</name> 15 <description>Demo project for Spring Boot</description> 16 17 <properties> 18 <java.version>1.8</java.version> 19 </properties> 20 21 <dependencies> 22 <dependency> 23 <groupId>org.springframework.boot</groupId> 24 <artifactId>spring-boot-starter-web</artifactId> 25 </dependency> 26 27 <dependency> 28 <groupId>org.springframework.boot</groupId> 29 <artifactId>spring-boot-starter-test</artifactId> 30 <scope>test</scope> 31 <exclusions> 32 <exclusion> 33 <groupId>org.junit.vintage</groupId> 34 <artifactId>junit-vintage-engine</artifactId> 35 </exclusion> 36 </exclusions> 37 </dependency> 38 </dependencies> 39 40 41 </project>

1 package com.example.demo; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 6 @SpringBootApplication(scanBasePackages = {"com.example"}) 7 public class DemoApplication { 8 9 public static void main(String[] args) { 10 SpringApplication.run(DemoApplication.class, args); 11 } 12 13 }

package com.example.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import java.util.HashMap; import java.util.Map; /** * <pre> * IndexController * </pre> * * @author wangyunpeng * @date 2020/1/8 11:33 */ @Controller public class IndexController { @RequestMapping(value="/", method = RequestMethod.GET) @ResponseBody public String home(){ return "home page"; } @RequestMapping(value="/index", method = RequestMethod.GET) @ResponseBody public Map<String, String> index(){ Map map = new HashMap<String, String>(); map.put("北京","北方城市"); map.put("深圳","男方城市"); return map; } }
idea項目統一設置父工程跳過maven測試:
統一測試一下父工程引用的包安裝到本地
IDEA—run面板多個服務顯示到Services面板
剛開始以為是沒打開Services面板的問題,於是在菜單處,view——Tool Windows——Services。打開了“Services”面板卻依然顯示如舊。
解決方式
在項目根目錄下 .idea/libraries/workspace.xml文件中,加入下面內容即可:
<component name="RunDashboard"> <option name="configurationTypes"> <set> <option value="SpringBootApplicationConfigurationType" /> </set> </option> </component>
重啟服務,就看到多個服務顯示在Services面板中:
IDEA 設置程序啟動參數:(Edit Configuration)
VM options: -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails Program arguments: --spring.profiles.active=dev Working directory: $MODULE_WORKING_DIR$
idea中安裝VisualVM監控jvm的圖文教程
安裝插件:VisualVM
配置IDEA
啟動運行監控
監控界面
GIT提交代碼信息模版:
在IDEA的Marketplace
中,搜索Git Commit Template
,就可以安裝這個插件。
提交git代碼
提交信息
選擇下面一個radio就可以了
提交類型Type
我們按照插件顯示的順序來說明一下。
feat
功能feature
的意思,也是最常用的。當你的功能有變更的時候,都可以采用這種類型的typefix
當然指的是bug修復docs
更新了文檔,或者更新了注釋style
代碼格式調整,比如執行了format、更改了tab顯示等refactor
重構代碼。指的是代碼結構的調整,比如使用了一些設計模式重新組織了代碼perf
對項目或者模塊進行了性能優化。比如一些jvm的參數改動,把stringbuffer改為stringbuilder等test
這個簡單,就是增加了單元測試和自動化相關的代碼build
影響編譯的一些更改,比如更改了maven插件、增加了npm的過程等ci
持續集成方面的更改。現在有些build系統喜歡把ci功能使用yml描述。如有這種更改,建議使用cichore
其他改動。比如一些注釋修改或者文件清理。不影響src和test代碼文件的,都可以放在這里revert
回滾了一些前面的代碼