简体   繁体   中英

IntelliJ External Libraries Compile Time Errors

I added an external library to my java project for fedmsg. I had my code compiling and working great. I needed something extra from the fedmsg class so I forked their repository and opened a pull request and the development got up stream.

Back to IntelliJ, I rebuilt the doc, src, and class .jar for the updated code and re-imported it back into IntelliJ. IntelliJ shows no errors and even autocompletes my code as seen here: 在此处输入图片说明

However, when I compile my code in IntelliJ AND the atlassian SDK, I get this error:

Error:(49, 19) java: cannot find symbol symbol: method disconnect() location: variable fedmsg of type org.fedoraproject.fedmsg.FedmsgConnection

The disconnect method is in the FedmsgConnection class, and that class exists as an external library where the error says it does:

在此处输入图片说明

Any idea what's going on? NOTE: When I compile the fedmsg-java .jars with sbt, there are obviously no errors.

EDIT: Another weird thing, if you "Search by symbol" ( Ctrl + shift + alt + N in IntelliJ), I can type "disconnect()" and the method from the fedmsg class shows up.

I am assuming that like me you have the Scala plugin but no others. If your SBT project is good and your IDEA project is confused then delete the '.idea' directory. Thus you will end up with just an SBT project. From IntelliJ IDEA you can now create the project again from scratch. To do this File -> Open and navigate to the SBT icon for your project. The SBT icon is three blue horizontal lines (hamburger bun). Probably you can leave all the settings as they are, just check the right JDK has been picked up.

I don't tend to compile within IntelliJ, but use ~package from SBT. However I do sometimes need to refresh the IntelliJ project whenever the build.sbt file has changed - something which IntelliJ informs you about if you go to the build.sbt file. For refreshing the project to work I need to make sure that the JVM options are lower than the defaults. Currently working for me is to have a 'Maximum heap size, MB' of 568 and 'VM parameters' of -XX:MaxPermSize=334M . Another problem I have had during refreshing is with comments in the build.sbt - I have had to strip them out to avoid an IntelliJ stack trace.

Whenever all the jar dependencies are correct but IntelliJ won't compile a project - evidenced by the syntax highlighting being all wrong, then just start over with IntelliJ. So far I have needed to do this on a fairly regular basis.

I got this fixed by manually importing (copying and pasting) the *.class files from the third party library SBT project (that were created by "sbt compile"), to where IntelliJ expects them to be, which is:

"(project root)\\classes"

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