Difference between revisions of "EclipseLink/Examples/MOXy/Spring/JAXBAnnotations"

From Eclipsepedia

< EclipseLink‎ | Examples‎ | MOXy‎ | Spring
Jump to: navigation, search
Line 4: Line 4:
 
   
 
   
 
== jaxb.properties ==
 
== jaxb.properties ==
Following is the <code>jaxb.properties</code> file that tells Spring to use EclipseLink JAXB - this properties file needs to be on the classpath:
+
Following is the <code>jaxb.properties</code> file that tells Spring to use EclipseLink JAXB - this file needs to be on the classpath:
 
<source lang="text">
 
<source lang="text">
 
javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory
 
javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory
Line 10: Line 10:
  
 
== EclipseLink ==
 
== EclipseLink ==
The latest version of EclipseLink can be found on the [http://www.eclipse.org/eclipselink/downloads/ EclipseLink download] page.  The <code>eclipselink.jar</code> file needs to be on the classpath.
+
The latest version of EclipseLink can be found on the [http://www.eclipse.org/eclipselink/downloads/ EclipseLink download] page.  <code>eclipselink.jar</code> needs to be on the classpath.
  
 
== Configuration: applicationContext.xml ==
 
== Configuration: applicationContext.xml ==
 +
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<beans
 +
    xmlns="http://www.springframework.org/schema/beans"
 +
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
 +
    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
 +
        <property name="contextPath" value="example.gettingstarted"/>
 +
    </bean>
 +
    <bean id="xmlHelper" class="example.gettingstarted.XMLHelper">
 +
        <property name="marshaller" ref="jaxbMarshaller"/>
 +
    </bean>
 +
</beans>
 +
</source>

Revision as of 13:32, 27 July 2010


In order to use EclipseLink JAXB with Spring, all that is required is a jaxb.properties file and eclipselink.jar. No other configuration is required.

jaxb.properties

Following is the jaxb.properties file that tells Spring to use EclipseLink JAXB - this file needs to be on the classpath:

javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory

EclipseLink

The latest version of EclipseLink can be found on the EclipseLink download page. eclipselink.jar needs to be on the classpath.

Configuration: applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans 
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="example.gettingstarted"/>
    </bean>
    <bean id="xmlHelper" class="example.gettingstarted.XMLHelper">
        <property name="marshaller" ref="jaxbMarshaller"/>
    </bean>
</beans>