Skip to content

Instantly share code, notes, and snippets.

@sjaakd
Created January 20, 2014 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjaakd/8518054 to your computer and use it in GitHub Desktop.
Save sjaakd/8518054 to your computer and use it in GitHub Desktop.
JAXB and List getters. someId2 generates only a getter, whereas someId1 generates a getter and a setter (without binding, out of the box). MapStructJaxbExample _2/src/main/resources/schema/xsd/test.xsd MapStructJaxbExample_2/pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>MapStructJaxbExample2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>MapStructJaxbExample 2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.build.resources[0].directory}/schema/</schemaDirectory>
<schemaIncludes>
<include>**/test.xsd</include> <!-- must be relative to schema -->
</schemaIncludes>
<extension>true</extension>
<verbose>true</verbose>
<specVersion>2.1</specVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://www.test.nl/xsd/test"
targetNamespace="http://www.test.nl/xsd/test"
elementFormDefault="qualified" version="1.0.0">
<element name="SomeFeature" type="test:SomeFeatureType" />
<complexType name="SomeFeatureType">
<sequence>
<element name="someId1" minOccurs="1" maxOccurs="1" type="string"/>
<element name="someId2" minOccurs="1" maxOccurs="5" type="string"/>
</sequence>
</complexType>
</schema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment