简体   繁体   中英

how to add external jar file in IntelliJ wihtout referencing to local directory

I am trying to add external jar files into my project in Intellij. I follow these steps: file->project structure->modules->dependencies->add jar or directory. However when it is done the location of that jar file is my local directory and when I build a project on a server it fails since there is no such directory for that jar on a server. How can I add a jar to the project without referencing a local directory?

You could deploy the entire project on the server as a uber JAR, meaning that the jar contains all of the dependent jars inside of it. You can accomplish that easily using maven shade, which is a simple plugin annotation in your .pom file (assuming you're using maven).

https://maven.apache.org/plugins/maven-shade-plugin/

There's a similar tool used in Gradle that is basically a port of the maven shade plugin. I've never used it before though, so I can't verify whether or not it is as easy to use or as effective.

https://github.com/johnrengelman/shadow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM