maven-dependency-plugin 目标/类 - 访问被拒绝
我有一个多模块项目,其中有一个父项目 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 moreCaused 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我刚刚也遇到了这个问题,使用
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
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
我刚刚遇到这个问题,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.
我有同样的问题。我已经通过这种方式解决了:
右键单击 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.
我尝试了多种方法来解决此问题:
没有成功。
然后我重新启动机器,
target
文件夹神奇地消失了。i tried several things to resolve this problem:
no success.
Then i rebooted the machine and the
target
folder was magically gone.只需从 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.