javax.persistence.Id을 파일에 주석으로 추가하고 Maven JAXB 플러그인을 통해 Java 객체로 생성하려고합니다. 그러나 클래스 javax.persistence.id에 대한 예외를 발견하지 못했습니다 javax.persistence maven 종속성에 포함되어 있는지 확인했다 및 종속성으로 당기는 maven 볼 수 있지만 jaxb 플러그 인을 통해 실행할 때 작동하지 않습니다. 여기 maven jaxb 플러그인을 통해 주석을 생성 할 수 없음
- 여기
내 XML<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:annox="http://annox.dev.java.net" jaxb:extensionBindingPrefixes="annox"> <jaxb:bindings schemaLocation="mytable.xsd"> <jaxb:bindings node="xs:complexType[@name='MyTable']/xs:sequence/xs:element[@name='id']"> <annox:annotate target="field"> <annox:annotate annox:class="javax.persistence.Id"/> </annox:annotate> </jaxb:bindings> </jaxb:bindings>
<xsd:complexType name="MyTable"> <xsd:sequence> <xsd:element name="id" type="xsd:int"/> </xsd:sequence> </xsd:complexType>
여기 - 입니다210
<dependencies> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2.9</version> </dependency> <dependency> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.4</version> </dependency> <dependency> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.4</version> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0.2</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.3</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <forceRegenerate>true</forceRegenerate> <schemaDirectory>myschema</schemaDirectory> <bindingIncludes> <include>binding.xjb</include> </bindingIncludes> <extension>true</extension> <args> <arg>-Xvalue-constructor</arg> <arg>-XtoString</arg> <arg>-Xequals</arg> <arg>-XhashCode</arg> <arg>-Xcopyable</arg> <arg>-Xannotate</arg> </args> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId>
JAXB2 - 기초 0.6.4
org.jvnet.jaxb2_commons JAXB2 - 기초 - 주석 0.6.4 org.jvnet.jaxb2_commons JAXB2 값-생성자 3.0
</plugins> </configuration> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <versionRange>[0.7.4,)</versionRange> <goals> <goal>generate</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build>
그러나 메이븐을 실행 -> 생성 - 소스을이 오류
Caused by: org.jvnet.annox.parser.AnnotationElementParseException: Could not parse the annotation element.
at org.jvnet.annox.parser.XAnnotationParser.parse(XAnnotationParser.java:90)
at org.jvnet.jaxb2_commons.plugin.annotate.AnnotatePlugin.annotate(AnnotatePlugin.java:387)
... 31 more
Caused by: org.jvnet.annox.annotation.AnnotationClassNotFoundException: Annotation class [javax.persistence.Id] could not be found.
... 33 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.Id
단순히 그때 추가 할 수 있습니다 내가 javax.persistence.Id가 함께 수입하기 참조 프로젝트의 모든 자바 클래스에 @Id 주석을 추가하는 경우를 얻을 문제 없어. maven & binding.xjb를 사용할 때 무엇이 잘못 될까요? 특수 효과를 제대로 정의하지 않습니까? 많은 감사합니다!