Spring-AOP-注释代码生成
我有个问题,希望有人能帮我 我使用Spring框架,我希望在我的一个域类中生成一个方法 我有一个域实体:Spring-AOP-注释代码生成,spring,aop,Spring,Aop,我有个问题,希望有人能帮我 我使用Spring框架,我希望在我的一个域类中生成一个方法 我有一个域实体: @Entity class AbcDomain { private int id; @CustomAnnotation(p1="x1", p2="y1") private String a; @CustomAnnotation(p1="x2", p2="y2") private String b; @CustomAnnotation(p1="3",
@Entity
class AbcDomain {
private int id;
@CustomAnnotation(p1="x1", p2="y1")
private String a;
@CustomAnnotation(p1="x2", p2="y2")
private String b;
@CustomAnnotation(p1="3", p2="y3")
private int c;
private Set<Integer> d;
... getters and setters
}
我在春天和aop都是新手,谁能帮我在哪里找到解决方案
谢谢您需要编译时AspectJ,然后您可以做一件事,这项技术在SpringRoo中被大量使用,因此如果您想要一个完整的示例,请创建一个SpringRoo项目
privileged aspect AbcDomain_Extension {
public String m() {
if ( "x1".equals(a) ) // "x1" comes from the annotation's p1 param
return "y1"; // "y1" comes from the annotation's p2 param
if ( "x2".equals(b) ) // "x2" comes from the annotation's p1 param
return "y2"; // "y2" comes from the annotation's p2 param
if ( c == 3 ) // 3 comes from the annotation's p1 param
return "y3"; // "y3" comes from the annotation's p1 param
}
}
您需要编译时AspectJ,然后您可以做一些称为SpringRoo中大量使用的技术,因此如果您想要一个完整的示例,请创建一个SpringRoo项目
privileged aspect AbcDomain_Extension {
public String m() {
if ( "x1".equals(a) ) // "x1" comes from the annotation's p1 param
return "y1"; // "y1" comes from the annotation's p2 param
if ( "x2".equals(b) ) // "x2" comes from the annotation's p1 param
return "y2"; // "y2" comes from the annotation's p2 param
if ( c == 3 ) // 3 comes from the annotation's p1 param
return "y3"; // "y3" comes from the annotation's p1 param
}
}