Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:改为使用BeanWrapper抽象类 #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<java.version>11</java.version>
<spring.version>5.2.15.RELEASE</spring.version>
<mysql.version>8.0.30</mysql.version>
<spring.boot.version>2.3.12.RELEASE</spring.boot.version>
<spring.boot.version>2.7.16</spring.boot.version>
</properties>

<modules>
Expand Down
10 changes: 5 additions & 5 deletions spring-dataops/spring-dataops-propertyEditor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ public interface PropertyEditor {
public class PropertyEditorDemo {

public static void main(String[] args) {
// 创建一个 BeanWrapperImpl 实例,用于操作 MyBean 类。
BeanWrapperImpl beanWrapper = new BeanWrapperImpl(MyBean.class);

// 为 Date 类型的属性注册自定义的属性编辑器 MyCustomDateEditor。
beanWrapper.overrideDefaultEditor(Date.class, new MyCustomDateEditor());
// 创建一个 BeanWrapper实例,用于操作 MyBean 类。
BeanWrapper beanWrapper = new BeanWrapperImpl(MyBean.class);
// 为 Date 类型的属性注册自定义的属性编辑器 MyCustomDateEditor。
beanWrapper.registerCustomEditor(Date.class, new MyCustomDateEditor());

// 设置 MyBean 类中名为 "date" 的属性值,使用字符串 "2023-12-5"。
// 这里会使用注册的 MyCustomDateEditor 来将字符串转换为 Date 对象。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.xcs.spring;

import com.xcs.spring.bean.MyBean;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.support.ResourceEditorRegistrar;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Date;

public class PropertyEditorDemo {

public static void main(String[] args) {
// 创建一个 BeanWrapperImpl 实例,用于操作 MyBean 类。
BeanWrapperImpl beanWrapper = new BeanWrapperImpl(MyBean.class);
// 创建一个 BeanWrapper实例,用于操作 MyBean 类。
BeanWrapper beanWrapper = new BeanWrapperImpl(MyBean.class);

// 为 Date 类型的属性注册自定义的属性编辑器 MyCustomDateEditor。
beanWrapper.overrideDefaultEditor(Date.class, new MyCustomDateEditor());
beanWrapper.registerCustomEditor(Date.class, new MyCustomDateEditor());

// 设置 MyBean 类中名为 "date" 的属性值,使用字符串 "2023-12-5"。
// 这里会使用注册的 MyCustomDateEditor 来将字符串转换为 Date 对象。
Expand Down