我们需要从存储库和服务开始向这些生成的类添加其他方法。为此,我们创建了额外的类,以便在未来的 JHipster 版本中更好地迁移。例如,
@Entity
public Foo {...}
@Repository
public interface FooExtendedRepository extends FooRepository {...}
@Service
public FooExtendedService extends FooService {...}
其中 FooExtendedService 肯定需要使用 FooExtendedService。有两种方法可以实现它。一种方法是在 FooExtendedService 中包含 FooExtendedRepository。另一种方法是在 FooService 类中将 FooRepository 属性更改为 FooExtendedService,并从 FooRepository 中删除 @Repository 注解。第一种方法很简单,代码更改最少,但这将使系统中的实例数量增加一倍。我们该使用哪种方法?
看一下:
https://www.jhipster.tech/tips/035_tip_combine_ Generation_and_custom_code.html
Pattern-3 Side-By-Side 是首选方法。您应该能够在 Youtube 上找到一些关于它的讨论。