IDEA 基础设置
IDEA配置JDK
####File>Project Structure
IDEA当前Maven工程配置
Ctrl+Shift+S->搜索maven
Mavan home path--设置maven安装包的bin文件夹所在的位置
User settings file--设置setting文件所在的位置
Local repository--设置本地仓库的(在setting.xml文件中配置)
IDEA创建Maven工程自动配置maven
File>New Projects Settings>Settings for New Projects..>Build,Execution,Deployment>Maven
IDEA Maven setting阿里云仓库、自定义仓库地址
setting.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>D:\study\IDEA\idea_apache_maven\apache-maven-3.6.3\maven-repssitort</localRepository> --> <!-- 自定义仓库地址--> <localRepository>D:\tools_work\apache-maven\repository</localRepository> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. |--> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> </servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <!-- 配置阿里云仓库--> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | |--> <profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings>
IDEA mvn控制台命令配置
mvn不是内部或外部命令
1.配置用户变量和系统变量的path:D:maven\apache-maven-3.5.0\bin;
2.cmd里运行 mvn -v 检查是否显示出maven的版本信息
3.若重启IDEA后的控制台里却提示不识别maven命令,此情况以管理员的身份运行IDEA即可。idea:No compiler is provided in this environment. Perhaps you are running on a JRE
1.在 D:maven\apache-maven-3.5.0\bin 目录下找到 mvn.cmd 文件,在文件的第一行添加一下命令(PS:后面是jdk的目录)
set JAVA_HOME=C:Program Files\Java\jdk1.8.0_141
IDEA配置SVN
Ctrl+Shift+S>Version Control>Subversion
IDEA配置SVN忽略文件
Ctrl+Shift+S>Editor>File Types
IDEA开启RunDashboard配置
Run Dashboard 它是一个代替Run窗口的一个更好清晰简洁的一个启动器。
如果我们需要启动多个窗口时,Run窗口不能让我们直观的看到我们看到每一个端口的变化。
一般有时候创建springboot项目的时候右下角可以提示你打开Run Dashboard,但是如果不提醒就需要自己配置了。配置方法一:
配置方法二:
1、打开.idea/workspace.xml
2、搜索RunDashboard
3、在<component name="RunDashboard"></component>
标签中添加如下配置<component name="RunDashboard"> <!--如需关闭注释掉此段配置即可--> <!--开启RunDashboard配置开始--> <option name="configurationTypes"> <set> <option value="SpringBootApplicationConfigurationType"></option> </set> </option> <!--开启RunDashboard配置结束--> <option name="ruleStates"> <list> <RuleState> <option name="name" value="ConfigurationTypeDashboardGroupingRule"/> </RuleState> <RuleState> <option name="name" value="StatusDashboardGroupingRule"/> </RuleState> </list> </option> </component>
需要重启
效果图如下:
IDEA护眼背景色
Ctrl+Shift+S>Editor>Color Scheme>General>Text>Default text
RGB(199,237,204), #C7EDCC
IDEA不带格式复制内容
####Ctrl+Alt+S>Editor>General:取消 Rich-Text Copy 的勾选
IDEA去除xml文件中的屎黄色背景
Ctrl+Alt+S>Editor>Inspections
IEDA字体设置
推荐字体
Consolas
Ctrl+Shift+S>Appearance & Behavior>Appearance
Ctrl+Shift+S>Editor>Font
IEDA显示行号
Ctrl+Shift+S->Editor->General->Appearance=>Show line numbers
IDEA配置文件路径
C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.3\bin\idea.properties
IDEA修改为Eclipse快捷键
Ctrl+Shift+S>Keymap
IDEA中文乱码
编码普通中文乱码:Ctrl+Shift+S --> Editor --> File encodings
properties文件中文乱码:Ctrl+Shift+S --> Editor --> File encodings
console控制台中文乱码
打开idea安装地址\bin中idea.exe.vmoptions 和idea64.exe.vmoptions 在最后加上
-Dfile.encoding=UTF-8
总结:最好所有都设置一遍,解决所有ide中文乱码问题。
IDEA关闭当前文件快捷键自定义
Ctrl+Shift+S—>Keymap—>main menu—>window—>editor tabs—>close
IDEA删除行快捷键自定义
Ctrl+Shift+S—>Keymap—>main menu—>window—>editor tabs—>Delete line
IDEA查看实现类快捷键自定义
Ctrl+Shift+S—>Keymap:
Implementations
IDEA未保存文件标识*设置
Ctrl+Shift+S>Editor>General>Editor Tabs>Mark modified(*) 勾选
IDEA快捷注释
1.Ctrl+Shift+S>Settings>Editor>LiveTemplates
By default expand with Enter
2.创建TemplateGroup模板组>创建LiveTemplate模板
3. 复制以下粘贴进Templatetext里面
/** * @Author: 马家立 * @Date: $DATE$ $TIME$ * @Description: * @Param: $param$ * @Return: $return$ */
4.配置适用地方,点击中下方的Define
5.配置属性,点击右边的Editvariables
6.点击Apply
IDEA VM options参数优化
Ctrl+Shift+S>Bulid,Execution,Deployment>Bulid Tools>Maven>Runner>VM Options
IDEA 如果不优化相关的配置会很卡,而且热加载也会很慢,每一次保存都在那儿等很久,所以配置好 VM options会好很多。
vm options 优化参数
-Xms1024m -Xmx8192m -XX:MaxMetaspaceSize=2048m -XX:MetaspaceSize2048m -XX:MaxMetaspaceSize=8192m -XX:MetaspaceSize=1024m -XX:ReservedCodeCacheSize=256m -XX:InitialBootClassLoaderMetaspaceSize=256M -XX:NewRatio=2 -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=6 -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled -Xss1024k -XX:+DisableExplicitGC -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:D:/idea.gc.log
部分参数说明
参数及其默认值 描述 -server 设置JVM使Server模式,特点是启动速度比较慢,但运行时性能和内存管理效率很高,适用于生产环境。在具有64位能力的JDK环境下默认启用该模式 -client 设置JVM使用Client模式,特点是启动速度比较快,但运行时性能和内存管理效率不高,通常用于客户端应用程序或开发调试;在32位环境下直接运行Java程序默认启用该模式 -Xms1024m 设置JVM初始堆内存1024M。此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存 -Xmx8192m 设置JVM最大堆内存为8192M -XX:MaxMetaspaceSize=8192m 设置持久代最大值为8192M -XX:MetaspaceSize=1024m 设置持久代初始值为1024M -XX:ReservedCodeCacheSize=256m 设置代码缓存的大小,用来存储已编译方法生成的本地代码 -XX:NewRatio=2 设置年轻代(包括1个Eden和2个Survivor区)与年老代的比值。表示年轻代比年老代为1:2 -XX:SurvivorRatio=8 设置年轻代中Eden区与Survivor区的比值。表示2个Survivor区(JVM堆内存年轻代中默认有2个大小相等的Survivor区)与1个Eden区的比值为1:1:8,即1个Survivor区占整个年轻代大小的1/10 -XX:MaxTenuringThreshold=6 表示一个对象如果在Survivor区(救助空间)移动了6次还没有被垃圾回收就进入年老代。如果设置为0的话,则年轻代对象不经过Survivor区,直接进入年老代,对于需要大量常驻内存的应用,这样做可以提高效率。如果将此值设置为一个较大值,则年轻代对象会在Survivor区进行多次复制,这样可以增加对象在年轻代存活时间,增加对象在年轻代被垃圾回收的概率,减少Full GC的频率,这样做可以在某种程度上提高服务稳定性 -Xss1024k 设置每个线程的栈大小。JDK5.0以后每个线程栈大小为1M,之前每个线程栈大小为256K。在相同物理内存下,减小这个值能生成更多的线程。但是操作系统对一个进程内的线程数还是有限制的,不能无限生成,经验值在3000~5000左右。线程栈的大小是个双刃剑,如果设置过小,可能会出现栈溢出,特别是在该线程内有递归、大的循环时出现溢出的可能性更大,如果该值设置过大(例如>2MB),就会影响到创建栈的数量,将会在很大程度上降低系统的性能,如果是多线程的应用,就会出现内存溢出的错误。应当根据应用的线程所需内存大小进行调整 -verbose:gc 开启gc日志 -XX:+PrintGCDetails 打印gc详情 -XX:+PrintGCTimeStamps 打印GC时间戳 -Xloggc:D:/temp/gclog/idea.gc.log 将日志输出到文 -XX:+PrintHeapAtGC 每次一次GC后,都打印堆信 在IDEA设置JVM运行参数,通常有以下三种方式:
代码配置
在编码中使用了System.setProperty对相应参数进行设置。Application设置
此种方式是上边所描述的“常用配置”,是日常开发中最常用到的配置方式。根据以下路径指示配置所需要的系统参数:Run–>Edit Configurations–>VM options全局配置
找到并打开安装IDEA时,你所指定的安装目录的bin文件夹;
在bin目录下,找到idea.exe.vmoptions文件;
打开该文件编辑并保存。优先级关系
代码配置>Application配置>全局配置
IDEA文件校验开启设置
Ctrl+Shift+S>Editor>Intentions