如何在运行Intellij 2020.1中的JUnit测试时禁用安全管理器?

huangapple go评论142阅读模式
英文:

How to disable Security Manager while running JUnit tests in Intellij 2020.1?

问题

我在Intellij 2020.1中运行几个JUnit测试时遇到以下错误:

Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/home/ubuntu/build-target/deployment/policies.properties" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    at java.security.AccessController.checkPermission(AccessController.java:886)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at java.io.FileInputStream.<init>(FileInputStream.java:127)

有人可以告诉我如何在Intellij中禁用安全管理器以避免出现上述错误吗?

我尝试通过Help -> Edit Custom VM Options设置-Dtests.security.manager=false,但仍然不起作用。

Java - OpenJDK 8

英文:

I am getting an error like below for few of my JUnit tests running in Intellij 2020.1.

Caused by: java.security.AccessControlException: access denied (&quot;java.io.FilePermission&quot; &quot;/home/ubuntu/build-target/deployment/policies.properties&quot; &quot;read&quot;)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
	at java.security.AccessController.checkPermission(AccessController.java:886)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
	at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:127)

Can someone let me know how can I disable Security Manager in Intellij to get around the error like above?

I have tried setting -Dtests.security.manager=false via Help -&gt; Edit Custom VM Options. But it is still not working?

Java - OpenJDK 8

答案1

得分: 2

你需要在你的运行配置的“VM选项”中设置“-Dtests.security.manager=false”。

英文:

You need to set "-Dtests.security.manager=false" in your Run configuration "VM options".

huangapple
  • 本文由 发表于 2020年7月23日 11:27:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/63046411.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定