我有點卡住註釋使用場景,我希望你的輸入。ClassNotFoundException與jaxb/annox和自定義註釋
給出的以下注釋 包com.tktserver.constraints(在相同的項目與ExistingCustomerValidator類沿着所定義的);
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { ExistingCustomerValidator.class })
@Documented
public @interface ExistingCustomerMatch {
String message() default "{customer.notfound}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
/**
* @return The field
*/
String field();
}
及以下JXB定製
<jaxb:bindings node="xsd:complexType[@name='customer']">
<annox:annotate>
<annox:annotate
annox:class="com.tktserver.constraints.ExistingCustomerMatch"
field="electronicUserId" />
</annox:annotate>
</jaxb:bindings>
我得到這個,當我產生通過Maven的(整個項目是由它處理)
Caused by: org.jvnet.annox.annotation.AnnotationClassNotFoundException: Annotation class [com.tktserver.constraints.ExistingCustomerMatch] could not be found.
... 32 more
Caused by: java.lang.ClassNotFoundException: com.bgc.ticketserver.constraints.ExistingCustomerMatch
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.jvnet.annox.parser.XAnnotationParser.parse(XAnnotationParser.java:76)
... 31 more
其他JSR-303我的消息來源註釋似乎工作正常。我想知道的是,我是否被循環依賴關係困在此處,即generate-sources先運行,然後編譯,因此在運行generate-sources時不存在ExistingCustomerMatch註釋類,或者這是完全不同的野獸。
感謝, 揚
嗨,你有沒有解決這個問題? –
是的,我最終把它建立爲主項目的依賴關係 – Ioannis