Getting IntelliJ IDEA to export the artifact (JAR) correctly is surpisingly difficult. This extension should assist with getting setup with IntelliJ.
You may need to reconfigure your project SDK, and you'll probably want to add a .gitignore file with the following content https://raw.githubusercontent.com/github/gitignore/master/Global/JetBrains.gitignore