Getting Started with Maven + Jaxb project
Hi,
I am complete new to IntellijIdea and i am looking for some step-by-step process to set up a basic project.
My project depends on Maven + Jaxb classes so i need a Maven project so that when i compile this project, the JAXB Objects are generated by Maven plugins. Now i started like this
1. I created a blank project say MaJa project
2. Added Maven Module to it
3. Added following settings in POM.XML
<?xml version="1.0" encoding="UTF-8"?> <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>MaJa</groupId> <artifactId>MaJa</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <executions> <execution> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <schemaDirectory>${basedir}/src/main/resource/api/MaJa</schemaDirectory> <packageName>com.rim.shopping.api.web.ws.v1.model</packageName> <outputDirectory>${build.directory}</outputDirectory> </configuration> </plugin> </plugins> </build> </project>
1. First of all, is it right settings ?
2. I tried clicking on Make/Compile 'MaJa' from Project > Right Click Menu and it didn't do anything.
I will be looking forward to yoru replies.
Please sign in to leave a comment.
Hello em,
About your pom.xml:
1.) You have to add version to 'javax.xml.bind:jaxb-api' dependency
2.) Looks like your have typo in '<schemaDirectory>' parameter, you type '${basedir}/src/main/resource/api/MaJa' instead of '${basedir}/src/main/resources/api/MaJa'
3.) Remove '<outputDirectory>' parameter. By default 'target/generated-sources/jaxb' directory used to store generated classes, it's more conveniently then 'target'
After creating/changing schema in ${basedir}/src/main/resources/api/MaJa you have to call "Generate Sources and Update Folders for All projects" action.