4

我有一个多模块项目,有一个父项目 A,两个子项目 B 和 C。项目 B 对项目 C 有依赖关系。我使用 maven-dependency-plugin 将 B 的依赖项复制到 lib/ 目录中目标/目录。因此,我可以使用 maven-assembly-plugin 将此 lib/ 目录包含在最终的 zip 中。问题是当我在项目 B 上运行 mvn clean package 时出现以下错误:

在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 还有 19 个

引起:java.io.FileNotFoundException: D:\path-to-projects-directory\C\target\classes(访问被拒绝)

在 java.io.FileInputStream.open(本机方法)

在 java.io.FileInputStream.(FileInputStream.java:120)

在 org.codehaus.plexus.util.io.FileInputStreamFacade.getInputStream(FileInputStreamFacade.java:36)

在 org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1141)

在 org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1048)

在 org.apache.maven.plugin.dependency.AbstractDependencyMojo.copyFile(AbstractDependencyMojo.java:192) ... 23 更多

有人有想法吗?

我在网上做了一些研究,发现存在这样的问题(请参阅http://jira.codehaus.org/browse/MWAR-192,这是针对战争的,但我对 JAR 也有类似的问题)。似乎无法访问项目C的target/classes目录来创建C.jar(C.jar必须包含在项目B的lib/目录中)。

谢谢

4

5 回答 5

4

我刚刚使用配置也遇到了这个问题

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <archive>
            <index>true</index>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
            <manifestEntries>
                <mode>development</mode>
                <url>${project.url}</url>
                <key>value</key>
            </manifestEntries>
        </archive>
    </configuration>
    ...
</plugin>

provided from the manifest customization example at http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html. I diagnosed it to the <index>true</index> as the problem went away when that part was commented out, and verified that this was an issue for versions 2.3.2, 2.3.1, 2.3, 2.2, 2.1 of the maven jar plugin.

According to the maven plugin jira -- see https://jira.codehaus.org/browse/MJAR-69 -- it's just been fixed

于 2012-01-26T11:41:08.733 回答
1

I just ran across this, the readOnly element apparently can cause an access denied message. The readOnly element is deprecated anyway, but I happened to use it from an older example.

于 2016-12-09T16:16:53.433 回答
1

I have the same issue.I have solved it in this way:

Right-click on traget folder > Properties > uncheck the Read-only option and tried problem solved.

enter image description here

于 2020-04-20T03:20:54.557 回答
0

i tried several things to resolve this problem:

  • changing permissions on the folder
  • removing the read-only attribute
  • deleting the folder from explorer
  • deleting the folder from elevated command prompt

no success.

Then i rebooted the machine and the target folder was magically gone.

于 2021-08-09T14:33:20.780 回答
0

The issue got resolved for me by just deleting the file from the eclipse problems view.

Attached the screenshot below.

Just right click on the error and click on Delete. This should fix it.

View Image

于 2022-01-18T11:36:25.847 回答