가끔씩 최종 XSD를 확인해 보고 싶은 경우가 생긴다.
물론 CXF와 같은 프레임워크를 이용하여 웹서비스를 개발하면 웹서비스 URI에 ?wsdl을 붙히면 WSDL을 살펴 볼 수도 있지만
개발 환경에서 @XmlRootElement, @XmlElement로 작업할 경우 매핑되는 XSD를 보고자 한다면 아래의 pom.xml 파일을 참고하기 바란다.
jdk1.6 (mustang)의 bin 폴더에 있는 xjc (xsd를 이용하여 java class 생성) 와 schemagen을 이용해도 동일한 결과를 얻을 수 있으나 maven plugin을 이용하는 편이 훨씬 수월하다.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.archnal.maven</groupId> <artifactId>jaxb-project</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>jaxb-project</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.0.1</version> <type>jar</type> <scope>test</scope> </dependency> </dependencies> <repositories> <repository> <id>java.net</id> <name>java.net Maven Repository</name> <url>https://maven-repository.dev.java.net/nonav/repository</url> <layout>legacy</layout> </repository> </repositories> <build> <plugins> <plugin> <groupId>com.sun.tools.jxc.maven2</groupId> <artifactId>maven-jaxb-schemagen-plugin</artifactId> <version>1.2</version> <executions> <execution> <phase>generate-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <includes> <include>**/com/archnal/sample/jaxb/**</include> </includes> <verbose>true</verbose> <source>1.6</source> </configuration> </plugin> <plugin> <groupId>com.sun.tools.xjc.maven2</groupId> <artifactId>maven-jaxb-plugin</artifactId> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <includeSchemas> <includeSchema>**/*.xsd</includeSchema> <includeSchema>**/*.dtd</includeSchema> </includeSchemas> <verbose>true</verbose> <source>1.6</source> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <pluginRepositories> <pluginRepository> <id>maven-repository.dev.java.net</id> <name>Java.net Maven 2 Repository</name> <url>http://download.java.net/maven/2</url> </pluginRepository> </pluginRepositories> </project>
댓글 없음:
댓글 쓰기