maven-dependency-plugin 目标/类 - 访问被拒绝

发布于 2024-12-26 09:46:57 字数 1218 浏览 5 评论 0原文

我有一个多模块项目,其中有一个父项目 A,以及两个子项目 B 和 C。项目 B 依赖于项目 C。我使用 maven-dependency-plugin 将 B 的依赖项复制到 lib/ 目录中目标/目录。因此,我可以使用 maven-assemble-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/目录中)。

谢谢

I have a multi module project with a parent project A, and two childs project B and C. Project B has a dependency on project C. I use the maven-dependency-plugin to copy the dependencies of B to a lib/ directory in the target/ directory. So, I can use the maven-assembly-plugin to include this lib/ directory in the final zip. The problem is I get the following error when I run mvn clean package on project B:

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more

Caused by: java.io.FileNotFoundException: D:\path-to-projects-directory\C\target\classes (Access is denied)

at java.io.FileInputStream.open(Native Method)

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

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

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

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

at org.apache.maven.plugin.dependency.AbstractDependencyMojo.copyFile(AbstractDependencyMojo.java:192)
... 23 more

Someone has an idea?

I've done some research on the web and I found that there is such an issue (see http://jira.codehaus.org/browse/MWAR-192 , that's for the wars but I have the similar problem with JAR). It seems that the target/classes directory of project C can't be accessed to create the C.jar (the C.jar must be included in the lib/ directory of project B).

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

望喜 2025-01-02 09:46:57

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

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

http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html。我将其诊断为 true 因为当该部分被注释掉后问题就消失了,并验证了这是版本 2.3.2、2.3.1 的问题, maven jar插件的2.3、2.2、2.1。

根据maven插件jira——参见https://jira.codehaus.org/browse/MJAR- 69——它刚刚被修复

I just ran into this issue as well using the configuration

<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

允世 2025-01-02 09:46:57

我刚刚遇到这个问题,readOnly 元素显然会导致访问被拒绝消息。无论如何,readOnly 元素已被弃用,但我碰巧在旧示例中​​使用了它。

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.

缱倦旧时光 2025-01-02 09:46:57

我有同样的问题。我已经通过这种方式解决了:

右键单击 traget 文件夹 >属性>取消选中只读选项并尝试解决问题。

在此处输入图像描述

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

谜兔 2025-01-02 09:46:57

我尝试了多种方法来解决此问题:

  • 更改文件夹的权限
  • 删除只读属性
  • 从资源管理器中删除文件夹
  • 从提升的命令提示符中删除文件夹

没有成功。

然后我重新启动机器,target 文件夹神奇地消失了。

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.

凶凌 2025-01-02 09:46:57

只需从 Eclipse 问题视图中删除该文件即可解决该问题。

附上下面的屏幕截图。

只需右键单击该错误,然后单击“删除”即可。这应该可以解决它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文