I am trying to create a multi-module project by using JPMS and Gradle multi-project functionalities. I have 3 modules for the testing: app, teacher and student. The student depends on the teacher and the app depends on both. Student and teacher modules have their own controller, service, entity, and repository. Each module has module-info.java file.
module app {
requires java.sql;
requires org.hibernate.orm.core;
requires spring.boot;
requires spring.data.jpa;
requires spring.boot.autoconfigure;
requires spring.core;
requires spring.beans;
requires spring.context;
requires teacher;
requires student;
opens az.chaypay.app to spring.core;
exports az.chaypay.app to spring.beans, spring.context;
}
module teacher {
requires static lombok;
requires spring.web;
exports az.chaypay.teacher to app;
exports az.chaypay.teacher.api to student;
exports az.chaypay.teacher.controller to spring.beans;
exports az.chaypay.teacher.service.impl to spring.beans;
opens az.chaypay.teacher.controller to spring.core;
opens az.chaypay.teacher.repository.dao to spring.core, com.fasterxml.jackson.databind, org.hibernate.orm.core;
}
module student {
requires static lombok;
requires com.fasterxml.jackson.databind;
requires spring.web;
exports az.chaypay.student to app;
exports az.chaypay.student.controller to spring.beans;
exports az.chaypay.student.service.impl to spring.beans;
opens az.chaypay.student.controller to spring.core;
opens az.chaypay.student.repository.dao to spring.core, com.fasterxml.jackson.databind, org.hibernate.orm.core;
requires teacher;
}
When I run my application with these settings everything works. Applications are successfully built and run. But IntelliJ complains about imports.
Package 'org.springframework.data.jpa.repository' is declared in module 'spring.data.jpa', but module 'student' does not read it
I don't understand that if Java has a problem with imports then why does my application run without errors. Why does my application run without requires statement?
