Spring multi-module JPMS project - exception only in IntellIJ

72 Views Asked by At

I'm learning myself Java Platform Module System, and it's going very hard. Currently I just trying figure out one problem with my IDE. I extracted essence into separate project: https://github.com/tomi127/JPMS-problem

Long story short: when I start com.data.Application through IntelliJ (PPM>Run/debug) server starts up without any problems. But when I'm making POST request to localhost:8080/storeInDB I got server error:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to module spring.core

But when I do mvn clean package and then run java -jar data-module-3.1.2.jar it works without any problems.

My questions are:

  • is somehow spring-boot-maven-plugin disables JPMS, or IntelliJ by default uses some special parameters for JVM?
  • what is best approach during development in such cases? Should I start server by maven (but it is uncomfortable) or IDE can be somehow configured to not have this type of errors?
0

There are 0 best solutions below