{"id":830,"date":"2026-09-17T13:07:05","date_gmt":"2026-09-17T07:37:05","guid":{"rendered":"https:\/\/www.cyberaka.com\/?p=830"},"modified":"2026-09-17T13:07:06","modified_gmt":"2026-09-17T07:37:06","slug":"maven-booted-my-spring-app-fine-intellij-didnt-heres-the-one-checkbox-fix","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=830","title":{"rendered":"Maven Booted My Spring App Fine. IntelliJ Didn&#8217;t. Here&#8217;s the One-Checkbox Fix."},"content":{"rendered":"<p>The setup: A Spring Boot service that booted perfectly with mvn spring-boot:run, but crashed immediately when launched from IntelliJ&#8217;s Run\/Debug configuration \u2014 same code, same machine, same dependencies.<\/p>\n<pre>\nThe error:\n  Exception in thread \"main\" org.springframework.beans.factory.BeanDefinitionStoreException:\n  Failed to read candidate component class: ...\n  Caused by: java.lang.IllegalArgumentException: Could not find class [com.azure.cosmos.models.CompositePathSortOrder]\n  Caused by: java.lang.ClassNotFoundException: com.azure.cosmos.models.CompositePathSortOrder\n<\/pre>\n<p>Spring&#8217;s classpath scanner hit an annotation referencing a class that, according to the JVM, didn&#8217;t exist.<\/p>\n<p><b>First instinct \u2014 wrong: <\/b>This looked like a version conflict. My local Maven repo had several versions of the library in question cached side by side, so a mismatch seemed like the obvious suspect. It wasn&#8217;t. Every version was internally consistent; the class was exactly where it should be.<br \/>\n<b>Finding the real cause: <\/b>Instead of guessing further, I asked Maven directly where this dependency actually comes from:<\/p>\n<pre>\nmvn dependency:tree -Dincludes=<the-missing-library>\n<\/pre>\n<p>The output told the whole story in one line:<\/p>\n<pre>\n  my-app\n  \\- some-transitive-library:jar:x.y.z:provided\n     \\- the-missing-library:jar:x.y.z:provided\n<\/pre>\n<p>provided scope. That&#8217;s Maven&#8217;s way of saying: &#8220;this dependency is needed to compile against, but something else \u2014 a container, an app server, the deployment environment \u2014 supplies it at runtime. Don&#8217;t bundle it.&#8221;<\/p>\n<p>Why the two tools disagreed:   <\/p>\n<li> mvn spring-boot:run treats the JVM it launches as that &#8220;runtime environment,&#8221; so it includes provided-scope dependencies on the exec classpath.\n<li> IntelliJ&#8217;s Run Configuration does not include provided-scope dependencies by default \u2014 and that&#8217;s the correct, intentional behavior for the scope&#8217;s contract. It&#8217;s not a bug; it&#8217;s IntelliJ doing exactly what provided is supposed to mean.\n<p>Same POM, same dependency graph, two different \u2014 both legitimate \u2014 interpretations of one Maven scope.<br \/>\nThe fix, once the cause was clear, took ten seconds: open the Run\/Debug Configuration, click Modify options, and enable:<\/p>\n<pre>   \n  \"Add dependencies with 'provided' scope to classpath\"\n<\/pre>\n<p>No POM edits. No version pinning. No cache invalidation. Rerun \u2014 boots clean.<\/p>\n<p><b>The lesson, generalized:<\/b> When a Maven-launched app and an IDE-launched app disagree on a missing class that genuinely exists in your dependency tree, don&#8217;t reach for version conflicts first. Check scope. mvn dependency:tree -Dincludes= will show you exactly which dependency brought a class in and under what scope \u2014 that single fact usually explains the whole discrepancy, and the fix is often a checkbox, not a rebuild.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The setup: A Spring Boot service that booted perfectly with mvn spring-boot:run, but crashed immediately when launched from IntelliJ&#8217;s Run\/Debug configuration \u2014 same code, same machine, same dependencies. The error: Exception in thread &#8220;main&#8221; org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: &#8230; Caused by: java.lang.IllegalArgumentException: Could not find class [com.azure.cosmos.models.CompositePathSortOrder] Caused by: java.lang.ClassNotFoundException: com.azure.cosmos.models.CompositePathSortOrder Spring&#8217;s [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,34],"tags":[],"class_list":["post-830","post","type-post","status-publish","format-standard","hentry","category-java","category-maven"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=830"}],"version-history":[{"count":1,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/830\/revisions"}],"predecessor-version":[{"id":831,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/830\/revisions\/831"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}