Skip to content

Entity Comment Generator

体华 edited this page Oct 18, 2013 · 9 revisions

利用javabean的注释生成实体properties

  • 使用步骤

pom.xml中添加如下配置

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.9</version>
      <configuration>
        <charset>UTF-8</charset>
        <doclet>org.beangle.commons.entity.comment.Generator</doclet>
        <docletArtifact>
          <groupId>org.beangle.commons</groupId>
          <artifactId>beangle-commons-model</artifactId>
          <version>${beangle.version}</version>
        </docletArtifact>
        <locale>zh_CN</locale>
        <useStandardDocletOptions>false</useStandardDocletOptions>
      </configuration>
    </plugin>
  </plugins>
</build>

控制台中运行mvn javadoc:javadoc,在项目的target/comment/目录中和源代码路径相同的package.en_US/package.zh_CN文件。

  • 样例

以下是UserBean(org.beangle.ems.security.model)的代码

/**
 * 系统用户
 * 记录账号、权限、状态信息.
 * 
 * @author dell,chaostone 2005-9-26
 */
@Entity(name = "org.beangle.ems.security.User")
public class UserBean extends LongIdTimeObject implements User, RestrictionHolder<UserRestriction> {

	/** 名称 */
	@Size(max = 40)
	@NotNull
	@Column(unique = true)
	protected String name;
	/** 用户姓名
	 * 用户真实姓名
	 */
	@NotNull
	@Size(max = 50)
	private String fullname;
	。。。,
	@Size(max = 100)
	@NotNull
	private String password;

生成的注释(target/comment/org/beangle/ems/security/model/package.zh_CN)如下:

UserBean = 系统用户
UserBean.name = 名称
UserBean.fullname = 用户姓名
#missing comment password

该文件可以用国际化和 生成表的注释

Clone this wiki locally