Spring OXM 快速指南



Spring OXM - 概述

Spring 框架使用全局编组器/解组器接口提供对象/XML 或 O/X 映射,并允许轻松切换 O/X 映射框架。将对象转换为 XML 的过程称为 XML 编组/序列化,而将 XML 转换为对象的转换称为 XML 解组/反序列化。

Spring 框架提供了一个 Marshaller 和 UnMarshaller 接口,其中 Marshaller 接口负责将对象编组到 XML,而 UnMarshaller 接口将 xml 反序列化为对象。以下是使用 Spring OXM 框架的主要好处。

  • 易于配置 - 使用 Spring bean 上下文工厂,编组器/解组器的创建非常容易,并且可以配置,而无需担心 O/X 库结构,如 JAXB 上下文、JiBX 绑定工厂等。编组器/解组器可以像任何其他 bean 一样进行配置。

  • 一致的接口 - Marshaller 和 UnMarshaller 是全局接口。这些接口在其他 O/X 映射框架之上提供了一个抽象层,并允许在它们之间切换而无需更改代码或只需进行少量代码更改。

  • 一致的异常处理 - 所有底层异常都被映射到 XmlMappingException 作为根异常。因此,开发人员无需担心底层 O/X 映射工具自己的异常层次结构。

编组器

Marshaller 是一个具有单个方法 marshal 的接口。

public interface Marshaller {
   /**
      * Marshals the object graph with the given root into the provided Result.
   */
   void marshal(Object graph, Result result)
      throws XmlMappingException, IOException;
}

其中 graph 是任何要编组的对象,而 result 是一个标记接口,用于表示 XML 输出。以下是可用的类型:

  • javax.xml.transform.dom.DOMResult - 表示 org.w3c.dom.Node。

  • javax.xml.transform.sax.SAXResult - 表示 org.xml.sax.ContentHandler。

  • javax.xml.transform.stream.StreamResult - 表示 java.io.File、java.io.OutputStream 或 java.io.Writer。

解组器

UnMarshaller 是一个具有单个方法 unmarshal 的接口。

public interface UnMarshaller {
   /**
      * Unmarshals the given provided Source into an object graph.
   */
   Object unmarshal(Source source)
      throws XmlMappingException, IOException;
}

其中 source 是一个标记接口,用于表示 XML 输入。以下是可用的类型:

  • javax.xml.transform.dom.DOMSource - 表示 org.w3c.dom.Node。

  • javax.xml.transform.sax.SAXSource - 表示 org.xml.sax.InputSource 和 org.xml.sax.XMLReader。

  • javax.xml.transform.stream.StreamSource - 表示 java.io.File、java.io.InputStream 或 java.io.Reader。

Spring OXM - 环境设置

本章将指导您如何准备开发环境以开始使用 Spring 框架。它还将教您如何在设置 Spring 框架之前在您的机器上设置 JDK、Maven 和 Eclipse -

设置 Java 开发工具包 (JDK)

您可以从 Oracle 的 Java 网站下载最新版本的 SDK - Java SE 下载。 您将在下载的文件中找到安装 JDK 的说明,请按照给定的说明安装和配置设置。最后设置 PATH 和 JAVA_HOME 环境变量以引用包含 java 和 javac 的目录,通常分别为 java_install_dir/bin 和 java_install_dir。

如果您正在运行 Windows 并已将 JDK 安装在 C:\jdk-11.0.11 中,则必须将以下行放入您的 C:\autoexec.bat 文件中。

set PATH=C:\jdk-11.0.11;%PATH% 
set JAVA_HOME=C:\jdk-11.0.11 

或者,在 Windows NT/2000/XP 上,您需要右键单击“我的电脑”,选择“属性”→“高级”→“环境变量”。然后,您需要更新 PATH 值并单击“确定”按钮。

在 Unix(Solaris、Linux 等)上,如果 SDK 安装在 /usr/local/jdk-11.0.11 中并且您使用的是 C shell,则必须将以下内容放入您的 .cshrc 文件中。

setenv PATH /usr/local/jdk-11.0.11/bin:$PATH 
setenv JAVA_HOME /usr/local/jdk-11.0.11

或者,如果您使用的是集成开发环境 (IDE),例如 Borland JBuilder、Eclipse、IntelliJ IDEA 或 Sun ONE Studio,则需要编译并运行一个简单的程序以确认 IDE 知道您已将 Java 安装在何处。否则,您需要按照 IDE 文档中给出的说明进行正确的设置。

设置 Eclipse IDE

本教程中的所有示例均使用 Eclipse IDE 编写。因此,我们建议您在您的机器上安装最新版本的 Eclipse。

要安装 Eclipse IDE,请从 www.eclipse.org/downloads 下载最新的 Eclipse 二进制文件。下载安装后,将二进制分发版解压缩到一个方便的位置。例如,在 Windows 上的 C:\eclipse 中,或在 Linux/Unix 上的 /usr/local/eclipse 中,最后适当地设置 PATH 变量。

可以通过在 Windows 机器上执行以下命令启动 Eclipse,或者您可以简单地双击 eclipse.exe

%C:\eclipse\eclipse.exe 

可以通过在 Unix(Solaris、Linux 等)机器上执行以下命令启动 Eclipse -

$/usr/local/eclipse/eclipse

成功启动后,如果一切正常,则应显示以下结果 -

Eclipse Home page

设置 Maven

在本教程中,我们使用 maven 来运行和构建基于 Spring 的示例。请按照 Maven - 环境设置 安装 maven。

Spring OXM - 创建项目

使用 eclipse,选择文件新建Maven 项目。勾选创建简单项目(跳过原型选择)并点击下一步。

输入详细信息,如下所示 -

  • groupId - com.tutorialspoint

  • artifactId - springoxm

  • version - 0.0.1-SNAPSHOT

  • name - Spring OXM

  • description - Spring OXM 项目

单击“完成”按钮,将创建一个新项目。

pom.xml

您可以检查 pom.xml 的默认内容

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.tutorialspoint</groupId>
   <artifactId>springoxm</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>Spring OXM</name>
   <description>Spring OXM Project</description>
</project>

现在我们已经准备好项目了,让我们在下一章中将以下依赖项添加到 pom.xml 中。

  • Spring Core

  • Spring OXM

  • JAXB

Spring OXM - 更新项目 JAXB2

更新 pom.xml 的内容,使其包含 spring core、spring oxm 和 jaxb 依赖项,如下所示 -

pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.tutorialspoint</groupId>
   <artifactId>springoxm</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>Spring OXM</name>
   <description>Spring OXM Project</description>
   <properties>
      <org.springframework.version>4.3.7.RELEASE</org.springframework.version>
      <org.hibernate.version>5.2.9.Final</org.hibernate.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <java.version>1.8</java.version>    
   </properties> 	
   <dependencies>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-oxm</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>javax.xml.bind</groupId>
         <artifactId>jaxb-api</artifactId>
         <version>2.3.1</version>
      </dependency>
      <dependency>
         <groupId>org.glassfish.jaxb</groupId>
         <artifactId>jaxb-runtime</artifactId>
         <version>2.3.1</version>
         <scope>runtime</scope>
      </dependency>      
   </dependencies>
   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>${java.version}</source>
               <target>${java.version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

创建一个名为Student.java的类,其中包含如下所示的 O/X 注解。

Student.java

package com.tutorialspoint.oxm.model;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Student{
   String name;
   int age;
   int id;

   public String getName(){
      return name;
   }
   @XmlElement
   public void setName(String name){
      this.name = name;
   }
   public int getAge(){
      return age;
   }
   @XmlElement
   public void setAge(int age){
      this.age = age;
   }
   public int getId(){
      return id;
   }
   @XmlAttribute
   public void setId(int id){
      this.id = id;
   }
}

src → main → resources中创建 applicationcontext.xml,其内容如下。

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"  
   xmlns:oxm="http://www.springframework.org/schema/oxm"  
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
   http://www.springframework.org/schema/oxm  
   http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">  

   <oxm:jaxb2-marshaller id="jaxbMarshaller">  
      <oxm:class-to-be-bound name="com.tutorialspoint.oxm.model.Student"/>  
   </oxm:jaxb2-marshaller>  
</beans>  

Spring OXM - 测试 JAXB2

创建一个名为OXMApplication.java的主类,其中包含编组器和解组器对象。此类的目的是使用编组器对象将学生对象编组到 student.xml 中,然后使用解组器对象将 student.xml 反序列化为学生对象。

示例

OXMApplication.java

package com.tutorialspoint.oxm;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
import com.tutorialspoint.oxm.model.Student;

public class OXMApplication {
   public static void main(String[] args) {
      ApplicationContext context = new ClassPathXmlApplicationContext("applicationcontext.xml");  
      Marshaller marshaller = (Marshaller)context.getBean("jaxbMarshaller");
      Unmarshaller unmarshaller = (Unmarshaller)context.getBean("jaxbMarshaller");

      // create student object
      Student student = new Student();
      student.setAge(14);
      student.setName("Soniya");

      try {
         marshaller.marshal(student, new StreamResult(new FileWriter("student.xml")));  
         System.out.println("Student marshalled successfully.");  
         FileInputStream is =  new FileInputStream("student.xml");
         Student student1 = (Student)unmarshaller.unmarshal(new StreamSource(is));
         System.out.println("Age: " + student1.getAge() + ", Name: " + student1.getName());
      } catch(IOException | XmlMappingException ex) {
         ex.printStackTrace();
      }
   }
}

输出

在 eclipse 中的文件内容区域中右键单击,然后选择作为 Java 应用程序运行并验证输出。

Oct 10, 2021 8:48:12 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1e127982: startup date 
[Sun Oct 10 20:48:12 IST 2021]; root of context hierarchy
Oct 10, 2021 8:48:12 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationcontext.xml]
Oct 10, 2021 8:48:13 PM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
INFO: Creating JAXBContext with classes to be bound [class com.tutorialspoint.oxm.model.Student]
Student marshalled successfully.
Age: 14, Name: Soniya

Spring OXM - 更新项目 XStream

更新 pom.xml 的内容,使其包含 xstream 依赖项,如下所示 -

pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.tutorialspoint</groupId>
   <artifactId>springoxm</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>Spring OXM</name>
   <description>Spring OXM Project</description>
   <properties>
      <org.springframework.version>4.3.7.RELEASE</org.springframework.version>
      <org.hibernate.version>5.2.9.Final</org.hibernate.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <java.version>1.8</java.version>    
   </properties> 	
   <dependencies>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-oxm</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>com.thoughtworks.xstream</groupId>
         <artifactId>xstream</artifactId>
         <version>1.4.8</version>
         <scope>compile</scope>
      </dependency>     
   </dependencies>
   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>${java.version}</source>
               <target>${java.version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

更新Student.java类,如下所示。

Student.java

package com.tutorialspoint.oxm.model;

public class Student {
   String name;
   int age;
   int id;

   public String getName(){
      return name;
   }
   public void setName(String name){
      this.name = name;
   }
   public int getAge(){
      return age;
   }
   public void setAge(int age){
      this.age = age;
   }
   public int getId(){
      return id;
   }
   public void setId(int id){
      this.id = id;
   }
}

src → main → resources中更新 applicationcontext.xml,其内容如下,以使用 XStreamMarshaller。XStreamMarshaller 对象可用于编组和解组。

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"  
   xmlns:oxm="http://www.springframework.org/schema/oxm"  
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
   http://www.springframework.org/schema/oxm  
   http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">  

   <bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">  
      <property name="annotatedClasses" value="com.tutorialspoint.oxm.model.Student"></property>  
   </bean>   
</beans>  

Spring OXM - 测试 XStream

更新主类OXMApplication.java,其中包含编组器和解组器对象。此类的目的是使用编组器对象将学生对象编组到 student.xml 中,然后使用解组器对象将 student.xml 反序列化为学生对象。

示例

OXMApplication.java

package com.tutorialspoint.oxm;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
import com.tutorialspoint.oxm.model.Student;

public class OXMApplication {
   public static void main(String[] args) {
      ApplicationContext context = new ClassPathXmlApplicationContext("applicationcontext.xml");  
      Marshaller marshaller = (Marshaller)context.getBean("xstreamMarshaller");
      Unmarshaller unmarshaller = (Unmarshaller)context.getBean("xstreamMarshaller");

      // create student object
      Student student = new Student();
      student.setAge(14);
      student.setName("Soniya");

      try {
         marshaller.marshal(student, new StreamResult(new FileWriter("student.xml")));  
         System.out.println("Student marshalled successfully.");  
         FileInputStream is =  new FileInputStream("student.xml");
         Student student1 = (Student)unmarshaller.unmarshal(new StreamSource(is));
         System.out.println("Age: " + student1.getAge() + ", Name: " + student1.getName());
      } catch(IOException | XmlMappingException ex) {
         ex.printStackTrace();
      }
   }
}

输出

在 eclipse 中的文件内容区域中右键单击,然后选择作为 Java 应用程序运行并验证输出。

Oct 11, 2021 9:18:37 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@29ca901e: startup date 
[Mon Oct 11 09:18:36 IST 2021]; root of context hierarchy
Oct 11, 2021 9:18:37 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationcontext.xml]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields 
(file:/C:/Users/intel/.m2/repository/com/thoughtworks/xstream/xstream/1.4.8/xstream-1.4.8.jar) 
to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Student marshalled successfully.
Age: 14, Name: Soniya

Spring OXM - 更新项目 Castor

更新 pom.xml 的内容,使其包含 castor 依赖项,如下所示 -

pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.tutorialspoint</groupId>
   <artifactId>springoxm</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>Spring OXM</name>
   <description>Spring OXM Project</description>
   <properties>
      <org.springframework.version>4.3.7.RELEASE</org.springframework.version>
      <org.hibernate.version>5.2.9.Final</org.hibernate.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <java.version>1.8</java.version>    
   </properties> 	
   <dependencies>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-oxm</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.codehaus.castor</groupId>
         <artifactId>castor-core</artifactId>
         <version>1.4.1</version>
      </dependency>   
      <dependency>
         <groupId>org.codehaus.castor</groupId>
         <artifactId>castor-xml</artifactId>
         <version>1.4.1</version>
      </dependency>
   </dependencies>
   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>${java.version}</source>
               <target>${java.version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

添加一个映射 xml,该 xml 用于 castor 映射以将Student类映射为mappings.xml,位于src → main → resources文件夹下,如下所示。

mappings.xml

<?xml version="1.0"?>  
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">  
<mapping>  
   <class name="com.tutorialspoint.oxm.model.Student" auto-complete="true" >  
      <map-to xml="Student"/>  
      <field name="id" type="integer">  
         <bind-xml name="id" node="attribute"></bind-xml>  
      </field>  
      <field name="name">  
         <bind-xml name="name"></bind-xml>  
      </field>  
      <field name="age">  
         <bind-xml name="age" type="int"></bind-xml>  
      </field>          
   </class>      
</mapping>

src → main → resources中更新 applicationcontext.xml,其内容如下,以使用 CastorMarshaller。CastorMarshaller 对象可用于编组和解组。

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"  
   xmlns:oxm="http://www.springframework.org/schema/oxm"  
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
   http://www.springframework.org/schema/oxm  
   http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">  

   <bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller">  
      <property name="targetClass" value="com.tutorialspoint.oxm.model.Student"></property>  
      <property name="mappingLocation" value="mappings.xml"></property>  
   </bean>  
</beans>  

Spring OXM - 测试 Castor

更新主类OXMApplication.java,其中包含编组器和解组器对象。此类的目的是使用编组器对象将学生对象编组到 student.xml 中,然后使用解组器对象将 student.xml 反序列化为学生对象。

示例

OXMApplication.java

package com.tutorialspoint.oxm;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
import com.tutorialspoint.oxm.model.Student;

public class OXMApplication {
   public static void main(String[] args) {
      ApplicationContext context = new ClassPathXmlApplicationContext("applicationcontext.xml");  
      Marshaller marshaller = (Marshaller)context.getBean("castorMarshaller");
      Unmarshaller unmarshaller = (Unmarshaller)context.getBean("castorMarshaller");

      // create student object
      Student student = new Student();
      student.setAge(14);
      student.setName("Soniya");

      try {
         marshaller.marshal(student, new StreamResult(new FileWriter("student.xml")));  
         System.out.println("Student marshalled successfully.");  
         FileInputStream is =  new FileInputStream("student.xml");
         Student student1 = (Student)unmarshaller.unmarshal(new StreamSource(is));
         System.out.println("Age: " + student1.getAge() + ", Name: " + student1.getName());
      } catch(IOException | XmlMappingException ex) {
         ex.printStackTrace();
      }
   }
}

输出

在 eclipse 中的文件内容区域中右键单击,然后选择作为 Java 应用程序运行并验证输出。

Oct 11, 2021 9:45:34 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6adede5: startup date 
[Mon Oct 11 09:45:34 IST 2021]; root of context hierarchy
Oct 11, 2021 9:45:35 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationcontext.xml]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.exolab.castor.xml.BaseXercesOutputFormat 
(file:/C:/Users/intel/.m2/repository/org/codehaus/castor/castor-xml/1.4.1/castor-xml-1.4.1.jar) 
to method com.sun.org.apache.xml.internal.serialize.OutputFormat.setMethod(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.exolab.castor.xml.BaseXercesOutputFormat
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations.
WARNING: All illegal access operations will be denied in a future release
Student marshalled successfully.
Age: 14, Name: Soniya
广告