Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven provided dependency will cause NoClassDefFoundError in intellij?

IntelliJ doesn't seem to put the provided dependency on the classpath when I run it, however I can do this successfully in Eclipse.
As it would be a lot more convenient for me, how can I do this in IntelliJ?

like image 838
zjffdu Avatar asked May 26 '15 08:05

zjffdu


People also ask

How do I change dependencies in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S , and go to Modules | Dependencies. In the next dialog, click Edit, and then click Configure next to the Include transitive dependencies option. Select the dependencies you want to include in the library and click OK.

Where is dependency coming in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Modules | Dependencies. Right-click the necessary dependency and select Analyze This Dependency.


1 Answers

I'm having the same problem. Intellij does not include provided dependencies in classpath. See this source. The best solution I found is to run it as maven app, using the exec:java goal. For example:

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

Better solutions are welcome.

like image 81
ivanprado Avatar answered Nov 15 '22 06:11

ivanprado