spring-beans-writer是我曾经为动态生成spring beans配置文件做的一个写入工具,托管地址:

https://github.com/bluejoe2008/spring-beans-writer

绝对原创,支持国人开源!

如下附上项目简单说明,抱歉原文是英文的,后面会能弄出中文版:)

spring-beans-writer

writer for spring IOC beans files

it is too easy to use, please see the test case:

https://github.com/bluejoe2008/spring-beans-writer/blob/master/test/cn/bluejoe/SpringBeansTest.java

example codes:

    SpringBeans beans = new SpringBeans();
beans.addBean(_database, "database");
beans.addBeans(_persons); SpringBeansWriter sbw = new SpringBeansWriter();
List<FilteredOutput> outputs = new ArrayList<FilteredOutput>();
outputs.add(new SimpleFilteredOutput(new File("spring_beans.xml")));
sbw.write(beans, outputs);

you can let spring-beans-writer save beans into multiple files:

    List<FilteredOutput> outputs = new ArrayList<FilteredOutput>();
//write tables into a spring_persons.xml
outputs.add(new SimpleFilteredOutput(new Matcher<EntityNode<?>>()
{
@Override
public boolean matches(EntityNode<?> x)
{
return x.getValue().getClass() == Person.class;
}
}, new File("spring_persons.xml"))); outputs.add(new SimpleFilteredOutput(new File("spring_databases.xml")));
sbw.write(beans, outputs);

on default, only annotated properties of a JavaBean will be written into output files. To annotate a JavaBean property, use '@XmlProperty':

@XmlProperty
public void setName(String name)
{
_name = name;
}

you can let spring-beans-writer write all JavaBean properties:

SpringBeansWriter sbw = new SpringBeansWriter(new DumpAllProperties());

acknowledgements

special thanks to suxianming@gmail.com, the guy who have ever worked on the project with me.

spring beans的写入工具——spring-beans-writer的更多相关文章

  1. 【Spring】8、Spring框架中的单例Beans是线程安全的么

    看到这样一个问题:spring框架中的单例Beans是线程安全的么? Spring框架并没有对单例bean进行任何多线程的封装处理.关于单例bean的线程安全和并发问题需要开发者自行去搞定.但实际上, ...

  2. 自定义beans.xml文件实现Spring框架

    经过一天的补习,学习文件加载,java反射,JDom等知识,到了晚上终于能够搭出一个基于配置文件的简单spring框架实现! 首先我们先看看这个问题: 下面是两副图左边是项目结构图,右边是UML图: ...

  3. Spring报错: org.springframework.beans.factory.support.BeanDefinitionValidationException: Couldn't find an init method named 'init' on bean with name 'car'(待解答)

    在Spring工程里,有一个Car类的bean,Main.java主程序,MyBeanPostProcessor.java是Bean后置处理器. 文件目录结构如下: Car.java package ...

  4. 获取Spring容器Bean对象工具类

    在开发中,总是能碰到用注解注入不了Spring容器里面bean对象的问题.为了解决这个问题,我们需要一个工具类来直接获取Spring容器中的bean.因此就写了这个工具类,在此记录一下,方便后续查阅. ...

  5. Spring Batch与ETL工具比较

    在实际应用中,在批处理中用得较多的是场景是数据同步.在做数据集成工作中,常常需要从源位置把数据同步到目标位置,以便于进行后续的逻辑操作.在做这种批处理工具时,在网上查资料,发现用得比较多的是kettl ...

  6. Spring统一返回Json工具类,带分页信息

    前言: 项目做前后端分离时,我们会经常提供Json数据给前端,如果有一个统一的Json格式返回工具类,那么将大大提高开发效率和减低沟通成本. 此Json响应工具类,支持带分页信息,支持泛型,支持Htt ...

  7. 使用spring tool suite(STS)工具创建spring boot项目和出现错误后的处理

    一.先下载配置maven环境 1.下载地址:http://maven.apache.org/download.cgi windows下下载zip文件 2.解压后放到某个文件目录下 3.配置环境变量 ( ...

  8. 一键式Spring集成工具 Spring Boot

    最近公司使用Spring boot进行开发,稍微了解一下,不过自我感觉把集中式配置applicate.properties搞明白,注解用过Spring MVC的boot绝对没问题的 比如拦截器:@As ...

  9. Spring实战6:利用Spring和JDBC访问数据库

    主要内容 定义Spring的数据访问支持 配置数据库资源 使用Spring提供的JDBC模板 写在前面:经过上一篇文章的学习,我们掌握了如何写web应用的控制器层,不过由于只定义了SpitterRep ...

随机推荐

  1. Linode各机房在中国访问速度性能测试

    最近因为google的各种被X的原因,想自己弄个VPS玩玩,比来比去都推荐linode. 因为各种性能测试工具都不靠谱,还是自己机器来的直接,虽然笨拙但是真实可信. 从测试结果上看,明显东京机房的速度 ...

  2. openstack api users list get token get servers

    curl -i \  -H "Content-Type: application/json" \  -d '{ "auth": {    "ident ...

  3. xml--通过SAX解析XML

    SAX的全称是Simple APIs for XML,也即XML简单应用程序接口.与DOM不同,SAX提供的访问模式是一种顺序模式,这是一种快速读写XML数据的方式.当使用SAX分析器对XML文档进行 ...

  4. Java split用法

    Java split用法 java.lang.string.split split 方法  将一个字符串分割为子字符串,然后将结果作为字符串数组返回. stringObj.split([separat ...

  5. WinForm中如何判断关闭事件来源于用户点击右上角的“关闭”按钮

    在C#的WinForm程序中,有的时候需要判定关闭请求从哪里发出来的.比如是用户点击了右上角的“关闭”按钮,还是调用了WinForm.Close()方法.最典型的是要知道点击右上角的“关闭”按钮发出的 ...

  6. appDelegate中的委托协议方法以及使用观察者模式获取其触发方法

    //当应用程序将要进入非活动状态执行,在此期间,应用程序不接受消息或事件,比如来电 - (void)applicationWillResignActive:(UIApplication *)appli ...

  7. go操作数据库 Go-SQL-Driver/MySQL 使用详解

    go操作mysql的驱动包很多,这里讲解当下比较流行的Go-SQL-Driver/MySQL1.下载安装 执行下面两个命令: 下载:go get github.com/Go-SQL-Driver/My ...

  8. 7Zip 来备份重要文件(夹)

    body { font-family: 宋体,Georgia,Helvetica,Arial,sans-serif,宋体,serif; font-size: 10.5pt; line-height: ...

  9. android自动化测试中hierarchyviewer和uiautomatorviewer获取控件信息的方式比对

    http://blog.csdn.net/itfootball/article/details/21777835 http://blog.csdn.net/chenbang110/article/de ...

  10. 记 Ubuntu14.04 Monodevelop 安装的两个问题

    1. Monodevelop 不能执行,显示错误 The assembly mscorlib.dll was not found or could not be loaded. 首先要确定mono安装 ...