创建一个ofbiz实例(由apache官网copy过来):
1. 通常将实例创建在hot-deploy文件下,我们这个例子也是:
1.1 创建文件夹hot-deploy/practice
1.2 在hot-deploy/practice下创建ofbiz-component.xml
<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="practice"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<webapp name="practice"
title="Practice"
server="default-server"
base-permission="OFBTOOLS"
location="webapp/practice"
mount-point="/practice"
app-bar-display="false"/>
</ofbiz-component>
1.3 创建文件夹hot-deploy/practice/webapp
创建文件夹hot-deploy/practice/webapp/practice
创建文件夹hot-deploy/practice/webapp/practice/WEB-INF(WEB-INF下有 controller.xml 和 web.xml)
1.4 在hot-deploy/practice/webapp/practice/WEB-INF下创建web.xml(文件我们从ofbiz/framework/example/webapp/birt/WEB-INF/web.xml下copy,但我们需要修改几个地方,修改部分如下)
<context-param>
<param-name>webSiteId</param-name>
<param-value>PRACTICE</param-value>
<description>A unique ID used to look up the WebSite entity to get information about catalogs, etc.</description>
</context-param>
<context-param>
<param-name>localDispatcherName</param-name>
<param-value>practice</param-value>
<description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
</context-param>
<context-param>
<param-name>mainDecoratorLocation</param-name>
<param-value>component://practice/widget/CommonScreens.xml</param-value>
<description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description>
</context-param>
1.5 在hot-deploy/practice/webapp/practice/WEB-INF下创建controller.xml,代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
<include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
<description>Practice Component Site Configuration File</description>
<owner>Copyright 2001-2009 The Apache Software Foundation</owner>
<handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
<!-- Request Mappings -->
<request-map uri="main">
<security https="false" auth="false"/>
<response name="success" type="view" value="main"/>
</request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
<view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/>
<!-- end of view mappings -->
</site-conf>
1.6 创建文件夹
hot-deploy/practice/webapp/practice/error并从ofbiz/framework/example/webapp/birt/error下将error.jsp拷贝过来
1.7 创建文件夹hot-deploy/practice/widget
1.8 在hot-deploy/practice/widget下创建PracticeScreens.xml
<?xml version="1.0" encoding="UTF-8"?>
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="main">
<section>
<widgets>
<label text="This is first practice"/>
</widgets>
</section>
</screen>
</screens>
至此,我们第一个小例子已经完成了,现在启动项目:
在控制台(cmd)找到项目路径xxx:\Workspaces\MyEclipse 8.5\ofbiz,运行: java -Xmx256M -jar ofbiz.jar
打开浏览器:http://localhost:8080/practice/control/main
屏幕会出现:
这样,我们的第一个例子变完成了。后续会更新每个文件的意思及流程