我正在try 使用JPMS和Gradle多项目功能创建一个多模块项目.我有3个测试模块:应用程序、教师和学生.学生依赖于老师,应用程序依赖于两者.学生和教师模块有自己的控制器、服务、实体和存储库.每个模块都有模块信息.java文件.
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;
}
当我使用这些设置运行应用程序时,一切都正常.应用程序已成功构建并运行.但IntelliJ抱怨进口.
包裹组织.springframework.数据jpa.存储库"在模块"spring中声明.数据jpa,但模块"学生"不读
我不明白,如果Java在导入方面有问题,那么为什么我的应用程序运行时没有错误.为什么我的应用程序运行时没有requires语句?