title: Spring Boot Application won't start (IllegalStateException could not evaluate condition on DevToolsDataSourceAutoConfiguration)
body: <p>I've tried to start my Spring Boot Application using IntelliJ. However, I cannot seem to make it work no matter whatever solutions I tried to implement to fix it. I believe it has something to do with <code>spring.autoconfigure</code> package, yet the root problem remains a mystery to me.</p>
  <p>I am trying to take advantage of both <code>Maven Multi Module System</code> as well as <code>Java Platform Module System</code>. Below is my <code>pom.xml</code>, <code>module-info.java</code> files and project structure.</p>
  <p><strong>Project Structure</strong></p>
  <p><a href="https://i.stack.imgur.com/KDi4U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KDi4U.png" alt="Simplified Project Structure" /></a></p>
  <p>Note that there is a parent <code>pom.xml</code> file and each sub-module has its own <code>pom.xml</code> file. Each sub-module has its own <code>module-info.java</code> file as well.</p>
  <p><strong>Parent pom.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.5.1&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;parent&lt;/artifactId&gt;
      &lt;version&gt;0.0.1&lt;/version&gt;
      &lt;name&gt;Demo Project&lt;/name&gt;
      &lt;description&gt;Demo Project Description&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;!--Add each module here --&gt;
      &lt;modules&gt;
          &lt;module&gt;webapp&lt;/module&gt;
          &lt;module&gt;persistence&lt;/module&gt;
          &lt;module&gt;facade&lt;/module&gt;
          &lt;module&gt;service&lt;/module&gt;
          &lt;module&gt;security&lt;/module&gt;
          &lt;module&gt;domain&lt;/module&gt;
      &lt;/modules&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;pluginManagement&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                      &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.5.1&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;mainClass&gt;com.example.MainApplication&lt;/mainClass&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;
                                  &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                                  &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                              &lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                      &lt;version&gt;3.8.1&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;source&gt;${java.version}&lt;/source&gt;
                          &lt;target&gt;${java.version}&lt;/target&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;!-- For testing --&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                      &lt;version&gt;3.0.0-M5&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/pluginManagement&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p><strong>webapp pom.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;parent&gt;
          &lt;artifactId&gt;parent&lt;/artifactId&gt;
          &lt;groupId&gt;com.example&lt;/groupId&gt;
          &lt;version&gt;0.0.1&lt;/version&gt;
      &lt;/parent&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;!--    &lt;version&gt;0.0.1&lt;/version&gt;--&gt;
  
      &lt;artifactId&gt;webapp&lt;/artifactId&gt;
  
      &lt;dependencies&gt;
          &lt;!-- Add dependencies for `webapp` module here --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.example&lt;/groupId&gt;
              &lt;artifactId&gt;facade&lt;/artifactId&gt;
              &lt;version&gt;0.0.1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.example&lt;/groupId&gt;
              &lt;artifactId&gt;domain&lt;/artifactId&gt;
              &lt;version&gt;0.0.1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p><strong>webapp module-info.java</strong></p>
  <pre><code>module webapp {
      requires domain;
      requires facade;
  
      requires spring.web;
      requires spring.boot;
      requires spring.boot.autoconfigure;
      requires spring.context;
  }
  </code></pre>
  <p><strong>Below is what I tried:</strong>
  So when I run the application as it is I get the following exception</p>
  <pre><code>Exception in thread &quot;restartedMain&quot; java.lang.IllegalAccessException: class org.springframework.boot.devtools.restart.RestartLauncher (in module spring.boot.devtools) cannot access class com.example.MainApplication (in module webapp) because module webapp does not export com.example to module spring.boot.devtools
      at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
      at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
      at java.base/java.lang.reflect.Method.invoke(Method.java:558)
      at spring.boot.devtools@2.5.1/org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
  </code></pre>
  <p>What I did to tackle this problem was changing webapp/module-info.java from</p>
  <pre><code>module webapp {
  }
  </code></pre>
  <p>to</p>
  <pre><code>open module webapp {
  }
  </code></pre>
  <p>Aftwerwards, though, I got the following exception</p>
  <pre><code>java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration due to javax/sql/DataSource not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
      at spring.boot.autoconfigure@2.5.1/org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:54) ~[spring-boot-autoconfigure-2.5.1.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:489) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.8.jar:na]
      at spring.context@5.3.8/org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.8.jar:na]
      at spring.boot@2.5.1/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.1.jar:na]
      at spring.boot@2.5.1/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.1.jar:na]
      at spring.boot@2.5.1/org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.1.jar:na]
      at spring.boot@2.5.1/org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.1.jar:na]
      at spring.boot@2.5.1/org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.1.jar:na]
      at webapp/com.example.MainApplication.main(MainApplication.java:10) ~[classes/:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
      at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
      at spring.boot.devtools@2.5.1/org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.5.1.jar:na]
  Caused by: java.lang.NoClassDefFoundError: javax/sql/DataSource
      at spring.boot.devtools@2.5.1/org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration$DevToolsDataSourceCondition.getMatchOutcome(DevToolsDataSourceAutoConfiguration.java:183) ~[spring-boot-devtools-2.5.1.jar:na]
      at spring.boot.autoconfigure@2.5.1/org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.5.1.jar:na]
      ... 21 common frames omitted
  Caused by: java.lang.ClassNotFoundException: javax.sql.DataSource
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
      ... 23 common frames omitted
  </code></pre>
  <ul>
  <li><p>I tried setting <code>spring.devtools.restart.enabled=false</code>. Same error followed.</p>
  </li>
  <li><p>I tried removing <code>spring-boot-devtools</code> from the list of dependencies. No error log yet start process exits with error code 0</p>
  </li>
  <li><p>I tried adding <code>h2</code> database dependency just to see what happens. No good.</p>
  </li>
  <li><p>I tried changing <code>spring-boot-devtools</code> <code>&lt;scope&gt;</code> value and even commenting it out. No good.</p>
  </li>
  <li><p>I tried excluding <code>DevToolsDataSourceAutoConfiguration.class</code> from AutoConfiguration. No good.</p>
  </li>
  <li><p>I tried adding <code>exports com.example;</code> to module-info.java. No good.</p>
  </li>
  <li><p>If I run <code>mvn test</code>, <code>mvn clean install</code>, <code>mvn spring-boot:run</code>, I don't get a single error and server is running just fine.</p>
  </li>
  <li><p><code>MainApplication.java</code> resides at <code>webapp/src/main/java/com/example/MainApplication.java</code>.</p>
  </li>
  </ul>
  <pre><code>package com.example;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  
  @SpringBootApplication
  public class MainApplication {
      public static void main(String[] args) {
          SpringApplication.run(MainApplication.class, args);
      }
  }
  
  </code></pre>
  <p>Why is <code>spring.autoconfigure</code> trying to find a <code>DataSource</code>? Is <code>IntelliJ</code>'s classpath messed up, and I need to update its dependencies manually? If I configure a proper database (such as <code>mssql</code>), would I still be facing this issue going forward?</p>
  <p>What confuses me the most is that I get no error triggering the server to run by typing <code>mvn spring-boot:run</code> command. To be honest, this is what makes me think the problem has to do with <code>IntelliJ's</code> classpath settings rather than project structure and configuration.</p>
  <p>Any help would be greatly appreciated. Thanks.</p>