Adding external library to artifact jar in IntelliJ IDEA

后端 未结 2 1541
孤街浪徒
孤街浪徒 2020-11-22 03:11

How can I add an external library to a project in IntelliJ IDEA so that when I build an artifact it still has access to the classes in the library?

I have created a

2条回答
  •  后悔当初
    2020-11-22 03:27

    You have 2 options here:

    • extract the dependency into the artifact jar so that the app is the single executable jar with all the dependencies
    • link the dependent jars via the Manifest.MF and copy them near the application main jar

    I've prepared a sample project that demonstrates both approaches: HelloWithDependencies.zip.

    The artifacts are produced into out\single and out\linked directories.

    Relevant configurations:

提交回复
热议问题