I'm new to Java modules. I've been trying to make DevTools work with jigsaw modules but I get the following error
Exception in thread "restartedMain" java.lang.IllegalAccessException: class org.springframework.boot.devtools.restart.RestartLauncher (in module spring.boot.devtools) cannot access class com.thanosfisherman.mancala.MancalaApplication (in module com.thanosfisherman.mancala) because module com.thanosfisherman.mancala does not export com.thanosfisherman.mancala to module spring.boot.devtools
What should I put into my module-info.java file in so that the app can run normally?
module-info.java
module com.thanosfisherman.mancala {
requires spring.web;
requires spring.boot.autoconfigure;
requires spring.boot;
}
Note that I'm using Gradle. Here is my gradle config script
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.thanosfisherman'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
runtimeOnly('org.springframework.boot:spring-boot-devtools')
runtimeOnly('org.postgresql:postgresql')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
EDIT: I read somewhere that spring uses reflection to read the module file so I have to add the open keyword like so.
open module com.thanosfisherman.mancala {
requires spring.boot.autoconfigure;
requires spring.boot;
requires spring.web;
}
Now My app runs normally without the devtools dependency but again throws a different error with the dependency.
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)