---
title: "OFBiz进阶--OFBiz开发之[ant create-component]创建模块"
author: "jatter"
date: "2017-10-29T13:42:12Z"
tags: []
categories: ["开源软件"]
slug: "ofbiz-ofbiz-ant-create-component"
draft: false
lastmod: "2017-10-29T13:42:12Z"
id: 2397956
url: "https://jatter.iteye.com/blog/2397956"
---

**OFBiz进阶--OFBiz开发之\[ant create-component]创建模块**  
(How to create a new component)

**目录的生成方式**  
   
1.**仿照已有模块**, 手工构建目录及相关必须文件和内容.   
              好处: 可以快速理解文件及目录结构;  
              坏处: 容易编写错误, 纠错比较困难.  
   
2. **使用 ant 指令生成**  
  此目录在项目中一般是由 ant指令\[create-component]创建的, 创建成功将在 OFBIZ\_HOME/hot-deploy 目录下生成  
    创建步骤分析: 执行指令\[ant create-component]  
      Component name: (e.g. mycomponent) \[Mandatory]  
                   -- 模块名称, 一般多个单词的全小写(如: learn)  
      Component resource name: (e.g. MyComponent) \[Mandatory]  
                   -- 模块资源名, 一般多个单词按\[驼峰式(单词首字母大写)]编写(如: Learn)  
      Webapp name: (e.g. mycomponent) \[Mandatory]  
                   -- 建站的站点地址名, 一般多个单词的全小写(如: learn)  
      Base permission: (e.g. MYCOMPONENT) \[Mandatory]  
                   -- 一般多个单词的全大写(如: LEARN)  
      Confirm: N/Y/n/y  
                   -- 确认生成吗? 否/是/否/是, 在确认生成后,   
                         将在 OFBIZ\_HOME/hot-deploy 目录下生成所有被模板设定好的模块及文件

**至此, 单个模块创建成功,**   
**在 hot-deploy 目录的模块不需要手动配置,**  
**现在 启动/重启 项目,**   
**直接访问 \[****http://localhost:8080/mycomponent****] 即可访问此模块**

 

 

**注意:**

    **新建的模块有初始权限, 需要将初始权限数据导入数据库才能正确访问,**

    **导入的数据文件依次是**

           **[LearnTypeData.xml;LearnSecurityPermissionSeedData.xml;**

                      **LearnSecurityGroupDemoData.xml; LearnDemoData.xml]**

 

    **关于导入****数据功能介绍请看****\[[OFBiz进阶--OFBiz开发之\[webtools\]-数据(Data)导入](http://ofbizer.iteye.com/blog/2303339 "OFBiz进阶--OFBiz开发之[webtools]-数据(Data)导入")****]!**