IDEA:无法附加测试报告到测试框架,或测试框架意外退出

在 IDEA 使用运行覆盖率测试时报了如下错误:

无法附加测试报告到测试框架,或测试框架意外退出

控制台日志:

At least 5 arguments expected but 1 found.
'C:\Users\JiaJia\AppData\Local\Temp\coveragearg'
Expected arguments are:

  1. data file to save coverage result
  2. a flag to enable tracking per test coverage
  3. a flag to calculate coverage for unloaded classes
  4. a flag to use data file as initial coverage, also use it if several parallel processes are to write into one file
  5. a flag to run coverage in sampling mode or in tracing mode otherwise
IDEA Error occurred during initialization of VM

IDEA 切换项目时弹出了 Out of memory 的提示框:

Xmx 设置成 2048 后,点 Shutdown 按钮,之后 IDEA 就再也启动不起来了。

直接使用 C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.4\bin 目录下的 idea.bat 启动会显示如下错误信息:

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

IDEA 中的 SVN 插件不见了

也不知道哪天断电,重启后 SVN 插件就没了,工程右键菜单,顶部的菜单,Setting 中的 Version Control 中都没有,重装了小乌龟也没用。
最终参照 idea svn 不见的问题 修复好了,原因是 IDEA 插件中的 SVN 插件被禁用掉了。

  1. File -> Settings -> Plugins

    勾上 Subversion Integration 插件,点 OK,重启 IDEA。

  2. VCS -> Enabled Version Control Integration

    选择 Subversion,点 OK。之后就可以正常使用 SVN 插件了。

IntelliJ IDEA 项目部署

Maven 项目的部署

1. 配置插件

pom.xml 文件中配置插件 maven-jar-pluginmaven-dependency-plugin

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        ...
    </parent>
    <artifactId>xxx</artifactId>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        ...
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.xxx.xxx.Application</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>

                <configuration>
                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    <excludeTransitive>false</excludeTransitive>
                    <stripVersion>false</stripVersion>
                </configuration>

                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>compile</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
IDEA 配置 maven(配置阿里云中央仓库)


原文:IDEA 配置 maven(配置阿里云中央仓库)


默认 /{username}/.m2/ 下面没有 settings.xml 文件,可以从 IDEA 安装目录的 \plugins\maven\lib\maven3\conf\ 目录下复制一份过来修改。

IDEA 自动重置 Language level 的解决办法

编译时出现【错误: -source 1.5 中不支持 lambda 表达式】错误,代码上显示【Usage of API documented as @since 1.6+】提示。

在【Project Structure】中将对应 Model 的 Language level 改成【Project default(8 - Lambdas, type annotation etc.)】后,代码上的提示消失了,但是通过 Maven 编译时仍然提示【错误: -source 1.5 中不支持 lambda 表达式】。

IntelliJ IDEA 自定义 getter & setter 模板

使用 Spring 框架并且使用 Swagger 自动生成接口文档。

使用 @ApiModelProperty 注解给属性设置说明时发现部分 boolean 型的备注都没显示出来。

比如下面属性:

@ApiModelProperty("是否锁定")
private boolean isLock;

public boolean isLock() {
    return isLock;
}

public void setLock(final boolean lock) {
    isLock = lock;
}
Intellij IDEA 常用快捷键

  1. Ctrl + J :弹出常用快捷键组合

  2. Alt + Enter :错误提示操作

  3. Shift + Space (默认为Ctrl + Space,但是和切换中文输入法快捷键冲突,建议设置为Shift + Space) :会弹出类名,方法名等

    设置方法: 找到 File=>Settings=>Keymap=>MainMenu=>Code=>Completion=>Basic,右键 Remove,再右键 Add Keyboard Shortcut,按下 Shift+ 空格,点 OK。

    注意

    之前因为使用了一个中文补丁包导致 File=>Settings 点了没有反应,把这个中文的 jar 删掉以后就好了。

  4. Ctrl + Alt + L :格式化整个文件

  5. Ctrl + Q :选中方法点 Ctrl + Q 会显示方法的 JavaDoc

IntelliJ IDEA Exception in thread "main" java.lang.ClassNotFoundException

新建了一个工程,编译没错,执行时提示如下错误:

Exception in thread "main" java.lang.ClassNotFoundException

最后发现是项目结构(Project Structure)=> Modules => Paths 里 Use modules compile output path 路径设置的不对.