java 生成jar idea,如何从IntelliJ中的java模块生成一个jar,并将依赖项放在一个单独的目录中?...

I have a module for which I want a jar to be created. So, here is what I do:

Adding a jar artifact, using the "From module with dependencies ..." option

In "Jar files from libraries" I select "copy to the output directory and link via manifest"

Leave all the defaults.

After that I can build the jar and all the dependencies would be placed near it in the same directory. So far so good.

Now I wish all the dependencies to be placed in a separate directory near the final jar. So, I repeat the same steps, but this time I create a new directory under the node in the artifact Output Layout tab (using the "Create Directory" button). Next I drag all the dependencies onto the new folder and apply the changes.

On the surface, everything is cool - the dependencies are indeed placed in the dedicated directory, but the MANIFEST.MF file is never updated! It should reference the dependencies via the new directory. As of now, the produced jar cannot be run - its dependencies are not visible.

This is unlike Eclipse, which does make sure the manifest file is correct when exporting a project as jar.

How can I workaround this problem, given that:

I want all the dependencies in a dedicated folder.

I want to use IntelliJ IDEA

I do not want to edit the manifest file manually.

I am using the latest download of the IntelliJ IDEA for windows - 11.1.2, build 117.418

Thanks.

解决方案

At the moment you have to update the classpath manually in the artifact configuration dialog so that it includes the subdirectory:

0kH0q.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值