zoukankan      html  css  js  c++  java
  • IDEA测试代码覆盖率时遇到的java.lang.reflect.InvocationTargetException问题

    IDEA测试代码覆盖率时遇到的java.lang.reflect.InvocationTargetException问题

    在使用IDEA 的单元测试的时候,生成代码覆盖率时遇到了以下问题。

    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
    FATAL ERROR in native method: processing of -javaagent failed
        at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:35)
        at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:28)
        ... 6 more
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at com.intellij.rt.coverage.instrumentation.Instrumentator.performPremain(Instrumentator.java:55)
        at com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.java:33)
        ... 12 more
    
    Process finished with exit code 1
    Exception in thread "main"

    开始毫无头绪,幸亏百度。找到了解决方案,但是其中的原因并没有弄清楚。

    参考博客:https://blog.csdn.net/luzijun1992/article/details/79983710

    1. 先看一下你自己idea.exe 的位置,这是我的E:IntelliJ IDEAIntelliJ IDEA 2016.1.1in
      1

    2. 找到idea.exe.vmoptions这个文件
      2

    3. 记事本打开最后加入一行-Djava.io.tmpdir=F:Temp ,这里要注意 F:Temp 是随意写的目录,但一定要保证它存在
      3

    4. 重新打卡IDEA 在运行就可以啦。

    5. 有的idea工具用的idea64.exe,所以修改的文件是idea64.exe.vmoptions

    img

  • 相关阅读:
    MySQL 幻读详解
    vue-layer 弹窗z-index问题
    vue-cli 路径不变 改变参数 显示不同组件
    mysql ---- limit使用方式
    mysql ---- 官网的测试数据库
    2020年度总结和2021年目标
    校招(春招实习 + 秋招)总结感想
    Centos8和7的区别(参照redhat)
    centos8 网卡命令(centos7也可用)
    排查linux系统是否被入侵
  • 原文地址:https://www.cnblogs.com/liangbin-2019-03-30/p/11504627.html
Copyright © 2011-2022 走看看