【问题标题】:Permission error in maven 3maven 3中的权限错误
【发布时间】:2012-05-23 06:36:27
【问题描述】:

我创建了一个示例项目,其中只有一个简单的 testng 依赖项。当我试图通过终端(通过 mvn compile)编译它时,我得到了这个错误。

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.axatrikx.Test.AppTest
Exception in thread "ThreadedStreamConsumer" org.apache.maven.surefire.util.NestedRuntimeException: null; nested exception is org.apache.maven.surefire.report.ReporterException: Unable to create file for report: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied); nested exception is java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
org.apache.maven.surefire.report.ReporterException: Unable to create file for report: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied); nested exception is java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at org.apache.maven.surefire.report.AbstractFileReporter.testSetStarting(AbstractFileReporter.java:74)
    at org.apache.maven.surefire.report.MulticastingReporter.testSetStarting(MulticastingReporter.java:44)
    at org.apache.maven.surefire.report.TestSetRunListener.testSetStarting(TestSetRunListener.java:104)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:94)
    at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:67)
    at java.lang.Thread.run(Thread.java:679)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ Test ---
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ Test ---
[INFO] Installing /home/amalbose/Workspace/Test/target/Test-0.0.1-SNAPSHOT.jar to /home/amalbose/.m2/repository/com/axatrikx/Test/0.0.1-SNAPSHOT/Test-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/amalbose/Workspace/Test/pom.xml to /home/amalbose/.m2/repository/com/axatrikx/Test/0.0.1-SNAPSHOT/Test-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.328s
[INFO] Finished at: Tue May 15 23:03:42 IST 2012
[INFO] Final Memory: 5M/245M
[INFO] ------------------------------------------------------------------------

我没有使用任何万能插件。这是我的 pom 文件。

<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>

    <groupId>com.axatrikx</groupId>
    <artifactId>Test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Test</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.5.2</version>
        </dependency>
    </dependencies>
</project>

请帮我解决这个问题。

编辑:我已授予整个工作区的 777 权限

【问题讨论】:

  • 先检查你是否有这个目录的写权限/home/amalbose/Workspace/Test/target/surefire-reports/.
  • 是的,我拥有工作区的完全权限
  • 尝试在你的 pom.xml 中明确指出 Maven 使用最新版本的 Surefire 插件。
  • @AndrewLogvinov 但我为什么要使用它?它只是一个简单的 testng 测试。
  • @axatrikx 好吧,如果您有其他想法,可以尝试一下 =) 您也可以尝试使用-X 选项执行构建以打印调试信息。

标签: maven maven-3 permission-denied maven-surefire-plugin


【解决方案1】:

首先确保您使用的 maven-surefire-plugin 版本正确,但看起来不像:

放入你的 pom 中:

 <build>
    ..
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.12</version>
        </plugin>
        ..
      </plugins>
    </pluginManagement>
   ..
 </build>

【讨论】:

    猜你喜欢
    • 2018-03-22
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多