私信发送成功
Watch Star Fork

白乔 / spring-beans-writerJava

用程序自动创建spring beans的配置文件,欢迎一起完善!
克隆/下载
Zhihong SHEN 最后提交于 2017-10-31 19:49 Delete README_CN.md
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
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)

你可以在登录后,对此项目发表评论

3_float_left_people 3_float_left_close