resultJP在Java中_JAVA中的序列化与反序列化高级知识

一、序列化

1、序列化的作用

Java平台允许我们在内存中创建可复用的Java对象,但一般情况下,只有当JVM处于运行时,这些对象才可能存在,即,这些对象的生命周期不会比JVM的生命周期更长。但在现实应用中,就可能要求在JVM停止运行之后能够保存(持久化)指定的对象,并在将来重新读取被保存的对象。Java对象序列化就能够帮助我们实现该功能。

2、序列化的原理

使用Java序列化,在保存对象时会将对象的状态保存为一组字节,在反序列化时,又将这些字节组装成对象,切记,对象序列化,序列化的是这个对象的状态,即,序列化的是他的成员变量,因为对象的序列化是不关注类中的静态变量的。在进行序列化的时候,不会调用被序列化对象的任何构造器。

3、序列化使用的场景

在持久化对象时,使用序列化。

使用RMI(远程方法调用),或在网络中传输对象时,进行对象的序列化,

4、默认的序列化机制

如果仅仅只是让某个类实现Serializable接口,而没有其它任何处理的话,则就是使用默认序列化机制。使用默认机制,在序列化对象时,不仅会序列化当前对象本身,还会对该对象引用的其它对象也进行序列化,同样地,这些其它对象引用的另外对象也将被序列化,以此类推。所以,如果一个对象包含的成员变量是容器类对象,而这些容器所含有的元素也是容器类对象,那么这个序列化的过程就会较复杂,开销也较大。

5、序列化的影响因素

transient关键字

当某个字段被声明为transient后,默认序列化机制就会忽略该字段。

public class Person implements Serializable {

...

transient private Integer age = null;

...

}

writeObject()方法与readObject()方法

被transient修饰的属性,如果一定需要序列化,可以在对应的类中添加两个方法:writeObject()与readObject()

public class Person implements Serializable {

...

transient private Integer age = null;

...

private void writeObject(ObjectOutputStream out) throws IOException {

out.defaultWriteObject();

out.writeInt(age);

}

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

in.defaultReadObject();

age = in.readInt();

}

}

测试类

public class SimpleSerial {

public static void main(String[] args) throws Exception {

File file = new File("person.out");

ObjectOutputStream oout = new ObjectOutputStream(new FileOutputStream(file));

Person person = new Person("John", 101, Gender.MALE);

oout.writeObject(person);

oout.close();

ObjectInputStream oin = new ObjectInputStream(new FileInputStream(file));

Object newPerson = oin.readObject(); // 没有强制转换到Person类型

oin.close();

System.out.println(newPerson);

}

}

writeObject()方法中会先调用ObjectOutputStream中的defaultWriteObject()方法,该方法会执行默认的序列化机制,在进行序列化时,会先忽略掉age字段。然后再调用writeInt()方法显示地将age字段写入到ObjectOutputStream中。readObject()的作用则是针对对象的读取,其原理与writeObject()方法相同。

writeObject()与readObject()都是private方法,是通过反射来调用的。

Externalizable接口

无论是使用transient关键字,还是使用writeObject()和readObject()方法,其实都是基于Serializable接口的序列化。JDK中提供了另一个序列化接口--Externalizable,使用该接口之后,之前基于Serializable接口的序列化机制就将失效.

public class Person implements Externalizable {

private String name = null;

transient private Integer age = null;

private Gender gender = null;

public Person() {

System.out.println("none-arg constructor");

}

public Person(String name, Integer age, Gender gender) {

System.out.println("arg constructor");

this.name = name;

this.age = age;

this.gender = gender;

}

private void writeObject(ObjectOutputStream out) throws IOException {

out.defaultWriteObject();

out.writeInt(age);

}

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

in.defaultReadObject();

age = in.readInt();

}

@Override

public void writeExternal(ObjectOutput out) throws IOException {

}

@Override

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

}

...

}

输出结果为:

arg constructor

none-arg constructor

[null, null, null]

注意:在上列的序列化中,你会发现,没有获取到任何的序列化信息,且调用了Person类的午餐构造器

Externalizable继承于Serializable,当使用该接口时,序列化的细节需要由我们自己来完成。如上所示的代码,由于writeExternal()与readExternal()方法未作任何处理,那么该序列化行为将不会保存/读取任何一个字段。这也就是为什么输出结果中所有字段的值均为空。

另外,使用Externalizable进行序列化时,当读取对象时,会调用被序列化类的无参构造器去创建一个新的对象,然后再将被保存对象的字段的值分别填充到新对象中,因此,在实现Externalizable接口的类必须要提供一个无参的构造器,且它的访问权限为public。

public class Person implements Externalizable {

private String name = null;

transient private Integer age = null;

private Gender gender = null;

public Person() {

System.out.println("none-arg constructor");

}

public Person(String name, Integer age, Gender gender) {

System.out.println("arg constructor");

this.name = name;

this.age = age;

this.gender = gender;

}

private void writeObject(ObjectOutputStream out) throws IOException {

out.defaultWriteObject();

out.writeInt(age);

}

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

in.defaultReadObject();

age = in.readInt();

}

@Override

public void writeExternal(ObjectOutput out) throws IOException {

out.writeObject(name);

out.writeInt(age);

}

@Override

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

name = (String) in.readObject();

age = in.readInt();

}

...

}

输出结果为:

arg constructor

none-arg constructor

[John, 31, null]

readResolve()方法

当我们使用Singleton模式时,应该是期望某个类的实例应该是唯一的,但如果该类是可序列化的,那么情况可能略有不同。

public class Person implements Serializable {

private static class InstanceHolder {

private static final Person instatnce = new Person("John", 31, Gender.MALE);

}

public static Person getInstance() {

return InstanceHolder.instatnce;

}

private String name = null;

private Integer age = null;

private Gender gender = null;

private Person() {

System.out.println("none-arg constructor");

}

private Person(String name, Integer age, Gender gender) {

System.out.println("arg constructor");

this.name = name;

this.age = age;

this.gender = gender;

}

...

}

public class SimpleSerial {

public static void main(String[] args) throws Exception {

File file = new File("person.out");

ObjectOutputStream oout = new ObjectOutputStream(new FileOutputStream(file));

oout.writeObject(Person.getInstance()); // 保存单例对象

oout.close();

ObjectInputStream oin = new ObjectInputStream(new FileInputStream(file));

Object newPerson = oin.readObject();

oin.close();

System.out.println(newPerson);

System.out.println(Person.getInstance() == newPerson); // 将获取的对象与Person类中的单例对象进行相等性比较

}

}

输出结果:

arg constructor

[John, 31, MALE]

false

此时,你会发现,它已经不再是一个单利对象,失去了单利的性质,为了能在序列化过程仍能保持单例的特性,可以在Person类中添加一个readResolve()方法,在该方法中直接返回Person的单例对象

public class Person implements Serializable {

private static class InstanceHolder {

private static final Person instatnce = new Person("John", 31, Gender.MALE);

}

public static Person getInstance() {

return InstanceHolder.instatnce;

}

private String name = null;

private Integer age = null;

private Gender gender = null;

private Person() {

System.out.println("none-arg constructor");

}

private Person(String name, Integer age, Gender gender) {

System.out.println("arg constructor");

this.name = name;

this.age = age;

this.gender = gender;

}

private Object readResolve() throws ObjectStreamException {

return InstanceHolder.instatnce;

}

...

}

当再次执行上方测试类的时候,执行结果为:

arg constructor

[John, 31, MALE]

true

无论是实现Serializable接口,或是Externalizable接口,当从I/O流中读取对象时,readResolve()方法都会被调用到。实际上就是用readResolve()中返回的对象直接替换在反序列化过程中创建的对象。

二、序列化知识结晶

1、序列化ID(serialVersionUID )的作用

private static final long serialVersionUID = 1L;

虚拟机是否允许反序列化,不仅取决于类路径和功能代码是否一致,一个非常重要的一点是两个类的序列化 ID 是否一致(就是 private static final long serialVersionUID = 1L)

2、静态变量序列化问题

public class Test implements Serializable {

private static final long serialVersionUID = 1L;

public static int staticVar = 5;

public static void main(String[] args) {

try {

//初始时staticVar为5

ObjectOutputStream out = new ObjectOutputStream(

new FileOutputStream("result.obj"));

out.writeObject(new Test());

out.close();

//序列化后修改为10

Test.staticVar = 10;

ObjectInputStream oin = new ObjectInputStream(new FileInputStream(

"result.obj"));

Test t = (Test) oin.readObject();

oin.close();

//再读取,通过t.staticVar打印新的值

System.out.println(t.staticVar);

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

}

}

// 输出结果为10

最后的输出是 10,对于无法理解的读者认为,打印的 staticVar 是从读取的对象里获得的,应该是保存时的状态才对。之所以打印 10 的原因在于序列化时,并不保存静态变量,这其实比较容易理解,序列化保存的是对象的状态,静态变量属于类的状态,因此 序列化并不保存静态变量。

3、父类序列化问题

要想将父类对象也序列化,就需要让父类也实现Serializable 接口。如果父类不实现的话的,就 需要有默认的无参的构造函数。

在父类没有实现 Serializable 接口时,虚拟机是不会序列化父对象的,而一个 Java 对象的构造必须先有父对象,才有子对象,反序列化也不例外。所以反序列化时,为了构造父对象,只能调用父类的无参构造函数作为默认的父对象。因此当我们取父对象的变量值时,它的值是调用父类无参构造函数后的值。如果你考虑到这种序列化的情况,在父类无参构造函数中对变量进行初始化,否则的话,父类变量值都是默认声明的值,如 int 型的默认是 0,string 型的默认是 null。

4、Transient序列化问题

Transient 关键字的作用是控制变量的序列化,在变量声明前加上该关键字,可以阻止该变量被序列化到文件中,在被反序列化后,transient 变量的值被设为初始值,如 int 型的是 0,对象型的是 null。

5、对敏感字段加密

场景

服务器端给客户端发送序列化对象数据,对象中有一些数据是敏感的,比如密码字符串等,希望对该密码字段在序列化时,进行加密,而客户端如果拥有解密的密钥,只有在客户端进行反序列化时,才可以对密码进行读取,这样可以一定程度保证序列化对象的数据安全。

原理

在序列化过程中,虚拟机会试图调用对象类里的 writeObject 和 readObject 方法,进行用户自定义的序列化和反序列化,如果没有这样的方法,则默认调用是 ObjectOutputStream 的 defaultWriteObject 方法以及 ObjectInputStream 的 defaultReadObject 方法。用户自定义的 writeObject 和 readObject 方法可以允许用户控制序列化的过程,比如可以在序列化的过程中动态改变序列化的数值。基于这个原理,可以在实际应用中得到使用,用于敏感字段的加密工作

private static final long serialVersionUID = 1L;

private String password = "pass";

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

// 对密码进行了加密

private void writeObject(ObjectOutputStream out) {

try {

PutField putFields = out.putFields();

System.out.println("原密码:" + password);

password = "encryption";//模拟加密

putFields.put("password", password);

System.out.println("加密后的密码" + password);

out.writeFields();

} catch (IOException e) {

e.printStackTrace();

}

}

// 对 password 进行解密,只有拥有密钥的客户端,才可以正确的解析出密码,确保了数据的安全。

private void readObject(ObjectInputStream in) {

try {

GetField readFields = in.readFields();

Object object = readFields.get("password", "");

System.out.println("要解密的字符串:" + object.toString());

password = "pass";//模拟解密,需要获得本地的密钥

} catch (IOException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

}

public static void main(String[] args) {

try {

ObjectOutputStream out = new ObjectOutputStream(

new FileOutputStream("result.obj"));

out.writeObject(new Test());

out.close();

ObjectInputStream oin = new ObjectInputStream(new FileInputStream(

"result.obj"));

Test t = (Test) oin.readObject();

System.out.println("解密后的字符串:" + t.getPassword());

oin.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

}

三、序列化跟反序列化常识注意点

1、在Java中,只要一个类实现了java.io.Serializable接口,那么它就可以被序列化。

2、通过ObjectOutputStream和ObjectInputStream对对象进行序列化及反序列化

3、虚拟机是否允许反序列化,不仅取决于类路径和功能代码是否一致,一个非常重要的一点是两个类的序列化 ID 是否一致(就是 private static final long serialVersionUID)

4、序列化并不保存静态变量。

5、要想将父类对象也序列化,就需要让父类也实现Serializable 接口。

6、Transient 关键字的作用是控制变量的序列化,在变量声明前加上该关键字,可以阻止该变量被序列化到文件中,在被反序列化后,transient 变量的值被设为初始值,如 int 型的是 0,对象型的是 null。

7、服务器端给客户端发送序列化对象数据,对象中有一些数据是敏感的,比如密码字符串等,希望对该密码字段在序列化时,进行加密,而客户端如果拥有解密的密钥,只有在客户端进行反序列化时,才可以对密码进行读取,这样可以一定程度保证序列化对象的数据安全。

8、在序列化过程中,如果被序列化的类中定义了writeObject 和 readObject 方法,虚拟机会试图调用对象类里的 writeObject 和 readObject 方法,进行用户自定义的序列化和反序列化。如果没有这样的方法,则默认调用是 ObjectOutputStream 的 defaultWriteObject 方法以及 ObjectInputStream 的 defaultReadObject 方法。用户自定义的 writeObject 和 readObject 方法可以允许用户控制序列化的过程,比如可以在序列化的过程中动态改变序列化的数值。

四、实例

1、 进行反序列化,并忽略某些不需要反序列化的属性

package com.qianfan123.mbr.service.report;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Date;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.BeansException;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.ApplicationContext;

import org.springframework.context.ApplicationContextAware;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.annotation.JsonIgnore;

import com.fasterxml.jackson.core.JsonParser;

import com.fasterxml.jackson.core.JsonProcessingException;

import com.fasterxml.jackson.databind.DeserializationContext;

import com.fasterxml.jackson.databind.JsonDeserializer;

import com.fasterxml.jackson.databind.JsonNode;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.databind.module.SimpleModule;

import com.hd123.rumba.commons.biz.entity.EntityNotFoundException;

import com.hd123.rumba.commons.biz.entity.OperateContext;

import com.hd123.rumba.commons.biz.entity.OperateInfo;

import com.hd123.rumba.commons.biz.entity.Operator;

import com.hd123.rumba.commons.biz.entity.StandardEntity;

import com.hd123.rumba.commons.biz.entity.VersionConflictException;

import com.hd123.rumba.commons.lang.Assert;

import com.qianfan123.mbr.annotation.Tx;

import com.qianfan123.mbr.api.MbrException;

import com.qianfan123.mbr.api.common.Nsid;

import com.qianfan123.mbr.api.consumption.Consumption;

import com.qianfan123.mbr.api.member.Member;

import com.qianfan123.mbr.dao.report.ReportEntity;

import com.qianfan123.mbr.dao.report.statistic.StatisticHistory;

import com.qianfan123.mbr.dao.report.statistic.StatisticHistoryDao;

import com.qianfan123.mbr.service.report.target.MemberDataTargetMarker;

import com.qianfan123.mbr.service.report.target.MemberOccuredAtDataTargetMarker;

import com.qianfan123.mbr.service.report.target.OccuredAtConsumptionDataTargetMarker;

import com.qianfan123.mbr.service.report.target.OccuredAtDailyConsumptionDataTargetMarker;

import com.qianfan123.mbr.service.report.target.OccuredAtDailyMemberDataTargetMarker;

import com.qianfan123.mbr.service.report.target.OccuredAtDailyRegisteredDataTargetMarker;

import com.qianfan123.mbr.service.report.target.OccuredAtMemberDataTargetMarker;

import com.qianfan123.mbr.service.report.target.TargetMarker;

import com.qianfan123.mbr.service.report.target.TenantConsumptionDataTargerMarker;

import com.qianfan123.mbr.service.report.target.TenantMemberDataTargerMarker;

import com.qianfan123.mbr.service.report.util.StatisticDataReverseUtils;

import com.qianfan123.mbr.utils.EntityUtils;

/**

* 报表统计服务抽象类

*

* @author huzexiong

*

*/

@Component

public abstract class AbstractStatisticService //

implements StatisticService, ApplicationContextAware {

private final Logger logger = LoggerFactory.getLogger(AbstractStatisticService.class);

private ApplicationContext applicationContext;

// 根据统计来源来获取统计元数据工厂

private Map, MakerFactory> makerFactories = new HashMap, MakerFactory>();

// 报表目标数据

private List targetMarkers = new ArrayList();

// 用于反序列化历史统计数据对象

private static final ObjectMapper MAPPER;

static {

MAPPER = new ObjectMapper();

MAPPER.setSerializationInclusion(NON_NULL);

MAPPER.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);

MAPPER.addMixIn(Member.class, MemberMixIn.class);

final SimpleModule module = new SimpleModule();

module.addDeserializer(Nsid.class, new JsonDeserializer() {

@Override

public Nsid deserialize(JsonParser jp, DeserializationContext ctxt)

throws IOException, JsonProcessingException {

JsonNode node = jp.readValueAsTree();

return new Nsid(node.get("namespace").asText(), node.get("id").asText());

}

});

MAPPER.registerModule(module);

}

/**

* 在反序列化时,忽略Member中的: fetchParts 属性 因为 fetchParts 对应两个set方法,反序列化会冲突

*

* @author wangxiaofeng

*

*/

static abstract class MemberMixIn {

@JsonIgnore

abstract Set getFetchParts();

}

@Autowired

private StatisticHistoryDao statisticHistoryDao;

@PostConstruct

public void init() {

makerFactories.put(Member.class, applicationContext.getBean(MemberMakerFactory.class));

makerFactories.put(Consumption.class,

applicationContext.getBean(ConsumptionMakerFactory.class));

targetMarkers.add(applicationContext.getBean(MemberDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(TenantConsumptionDataTargerMarker.class));

targetMarkers.add(applicationContext.getBean(TenantMemberDataTargerMarker.class));

targetMarkers.add(applicationContext.getBean(OccuredAtConsumptionDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(OccuredAtMemberDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(OccuredAtDailyConsumptionDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(OccuredAtDailyMemberDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(OccuredAtDailyRegisteredDataTargetMarker.class));

targetMarkers.add(applicationContext.getBean(MemberOccuredAtDataTargetMarker.class));

}

/**

* 获取统计数据源

*

* @param tenant

* 租户, not null

* @param uuid

* UUID, not null

* @return

*/

public abstract S get(String tenant, String uuid);

public abstract Class> getClassType();

@Tx

@Override

public void run(String tenant, String uuid) throws MbrException, VersionConflictException {

Assert.hasText(tenant);

Assert.hasText(uuid);

// 查询统计历史信息

StatisticHistory statisticHistory = statisticHistoryDao.get(tenant, uuid);

S last = restore(statisticHistory);

// 根据不同的统计来源获取对应的元数据工厂

MakerFactory makerFactory = makerFactories.get(getClassType());

try {

// 先对历史数据进行反向操作,并持久化

if (null != last) {

builder(last, makerFactory, -1);

}

// 获取统计源

S source = get(tenant, uuid);

if (null != source) {

builder(source, makerFactory, 1);

}

if (null == last && null == source) {

logger.info("未查询到源数据和历史数据:tenant[{}],uuid[{}],class[{}],统计忽略。", //

tenant, uuid, getClassType().getName());

return;

}

// 统计完成,记录历史。

if (null == last) {// 新增

insertHistory(tenant, source);

} else if (null != source) {// 更新

modifyHistory(statisticHistory, source);

} else {// 删除

removeHistory(statisticHistory);

}

} catch (Exception e) {

e.printStackTrace();

logger.error("报表统计异常:" + e.getMessage());

throw new MbrException(e);

}

}

/**

* 对获取到的历史统计数据信息进行反序列化操作

*

* @param statisticHistory

* @return

* @throws MbrException

*/

private S restore(StatisticHistory statisticHistory) throws MbrException {

if (null == statisticHistory) {

return null;

}

S last = null;

try {

last = (S) MAPPER.readValue(statisticHistory.getData(), getClassType());

} catch (IOException e) {

throw new MbrException(e);

}

return last;

}

/**

* 生成报表数据并进行持久化操作

*

* @param source

* 统计数据源,not null

* @param makerFactory

* 相应的统计元数据工厂 , not null

* @param base

* 1 或 -1 ,表示是历史数据还是新的统计源数据

*/

private void builder(S source, MakerFactory makerFactory, int base) throws Exception,

VersionConflictException, IllegalArgumentException, EntityNotFoundException {

// 根据传入的统计来源,产生相应的元数据列表

List metaDatas = makerFactory.makeValues(source);

// base = -1 表示是历史表中的统计数据

if (-1 == base) {

StatisticDataReverseUtils.reverse(metaDatas, -1);

}

// 进行报表数据更新与保存等操作

for (TargetMarker targetMarker : targetMarkers) {

if (getClassType() != targetMarker.getSourceType()) {

continue;

}

// 根据元统计数据和来源数据生成报表数据

ReportEntity report = targetMarker.make(source, metaDatas);

if (null == report) {

continue;

}

// 获取数据库统计数据信息

ReportEntity db = targetMarker.getReportEntityDao().getBy(report);

// 如果第一次生成报表数据信息,则进行插入操作,否则,先进行数据合并,再更新

if (null == db) {

EntityUtils.setOperateInfo(report, getOperationContext());

targetMarker.getReportEntityDao().insert(report);

} else {

// 合并数据

ReportEntity merge = targetMarker.merge(report, db);

EntityUtils.setOperateInfo(merge, getOperationContext());

targetMarker.getReportEntityDao().update(merge);

}

}

}

/**

* 插入历史统计数据

*

* @param tenant

* 租户

* @param entity

* 相应实体

* @return

* @throws JsonProcessingException

*/

private StatisticHistory insertHistory(String tenant, S entity) throws JsonProcessingException {

StatisticHistory his = new StatisticHistory();

his.setTenant(tenant);

his.setStatisticUuid(entity.getUuid());

his.setLastUpdated(getLastUpdated(entity));

his.setData(MAPPER.writeValueAsString(entity));

EntityUtils.setOperateInfo(his, getOperationContext());

statisticHistoryDao.insert(his);

return his;

}

private Date getLastUpdated(S entity) {

OperateInfo operateInfo = entity.getLastModifyInfo();

Assert.notNull(operateInfo);

return operateInfo.getTime();

}

private void modifyHistory(StatisticHistory his, S entity)

throws JsonProcessingException, VersionConflictException {

his.setLastUpdated(getLastUpdated(entity));

his.setData(MAPPER.writeValueAsString(entity));

EntityUtils.setLastModifyInfo(his, getOperationContext());

statisticHistoryDao.update(his);

}

private void removeHistory(StatisticHistory his) throws VersionConflictException {

statisticHistoryDao.delete(his);

}

protected OperateContext getOperationContext() {

OperateContext context = new OperateContext();

context.setOperator(new Operator("统计报表", null));

context.setTime(new Date());

return context;

}

@Override

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

this.applicationContext = applicationContext;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值