The above maven dependency will throw a NoClassDefFoundError in intellij?

IntelliJ does not seem to apply the provided class path dependency when it starts, however I can do it successfully in Eclipse .
How would I be much more comfortable how to do this in IntelliJ ?

+5
source share
3 answers

I have the same problem. Intellij does not include the provided dependencies in the pathpath. See this source . The best solution I found is to run it as a maven application using the exec:java target. For instance:

 exec:java -Dexec.classpathScope=compile -Dexec.mainClass=com.splout.db.integration.NShardEnsemble -Dexec.args=4 

Better solutions are welcome.

+5
source

Does it work in Maven via the command line? The behavior seems right. Eclipse is used to handle the class path poorly, so I think it still does.

There is a difference if you run something in Test source root or Source root , since the scope provided is available only in the compilation class and test .

If you run the test or the main method in Test source root , then it can use the provided dependencies, but if you try to execute something (via IntelliJ or exec-maven-plugin ) in the Source root , then it will fail on a ClassNotFoundException.

+1
source

this answer is based on @Meo's answer.

ALT + Enter to create a unit test:

enter image description here

then run it:

enter image description here

0
source

All Articles