IntelliJ IDEA使用小技巧

Home / Article MrLee 2019-3-26 2936

熟练掌握一个IDE,开发效率将会有质的提升。下面罗列一些常用的技巧。

IntelliJ IDEA设置自动导入包 

IntelliJ IDEA可以自动优化导入包,但是有多个同名的类位于不同的包时,需要自己手动使用Alt + Enter进行导入。

  1. Settings→Editor→General→Auto Import
  2. Optimize imports on the fly和Add unambiguous imports on the fly

快捷键(eclipse)

很多之前做Java都是用的eclipse,对于eclipse快捷键使用非常了解。IntelliJ IDEA也是支持eclipse的快捷键的

IntelliJ IDEA 源值1.5已过时

不知为何,IntelliJ IDEA 默认JDK版本设置是1.5,所以一直会提示有该死的报警。右键工程->选择maven->打开settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <profiles>
        <profile>
            <id>jdk-1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

添加JDK的<profile>部分即可。然后修改工程的pom文件,添加以下代码

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

后续有新的发现陆续更新……

本文链接:https://www.it72.com/12529.htm

推荐阅读
最新回复 (0)
返回