在我的maven项目中,我有2个模块:
com.example.common
和
com.example.myfeature
在common
模块中,我有一个包含entities
类的程序包名称@Entity
在myfeature
模块中,我有一个包含vos
或DTO
类的程序包名称Value Object
。
com.example.common
+-----------------entities
+-------------------------Doctor.java
com.example.myfeature
+-----------------vos
+--------------------DoctorDTO.java
+-----------------repository
+--------------------DoctorRepository.java
我这样声明了@SqlResultSetMapping
:
@SqlResultSetMapping(
name = "resultMappingQuery",
classes = @ConstructorResult(
targetClass = DoctorDTO.class,
columns = {
@ColumnResult(name = "doctorId", type = Long.class),
@ColumnResult(name = "gender", type = Gender.class),
@ColumnResult(name = "dateOfBirth", type = Date.class),
@ColumnResult(name = "description", type = String.class),
@ColumnResult(name = "avatarImg", type = String.class),
@ColumnResult(name = "title", type = String.class),
@ColumnResult(name = "addressTitle", type = String.class),
@ColumnResult(name = "address", type = String.class),
@ColumnResult(name = "department", type = String.class),
})
)
如果我在公共模块中声明了@SqlResultSetMapping
,则必须将DoctorDTO
的{{1}}导入myfeature
。
问题是我无法将common
模块导入到myfeature
模块中,所以我会提出紧密耦合问题。
我想在common
模块中的某个地方声明@SqlResultSetMapping
。
我该怎么做?