7.21 杭州源创会火热报名中,一起来看看移动开发如何紧跟浪潮?
Watch Star Fork

白乔 / spring-beans-writerJava

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
用程序自动创建spring beans的配置文件,欢迎一起完善!
Loading...
README.md 1.89 KB

中文版:https://github.com/bluejoe2008/spring-beans-writer/blob/master/README_CN.md

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

import spring-beans-writer:

<!-- https://mvnrepository.com/artifact/com.github.bluejoe2008/spring-beans-writer -->
<dependency>
    <groupId>com.github.bluejoe2008</groupId>
    <artifactId>spring-beans-writer</artifactId>
    <version>0.9</version>
</dependency>

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 require 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.

项目点评 ( 1 )

你可以在登录后,发表评论

11_float_left_people 11_float_left_close