OpenBravo 在eclipse下项目建立
介绍
Openbravo现在完全可以在eclipse环境下开发,测试,部署,包括4个项目openbravo,core, trl 和wad,在相应目录下都有eclipse的项目文件,项目可以直接导入到eclipse中。
环境需求
· Java Development Kit (JDK) 6.
· Apache Tomcat 6.x.
· Apache Ant 1.7.
· PostgreSQL 8.3.x.
开发工具
· Eclipse IDE for Java EE Developers.
源代码
· Openbravo ERP 2.5
从SVN上下载代码
从 Openbravo Subversion (SVN) repository 下载源代码,不要从sourceforge上下载,sourceforge上特别慢。
在dos下转到d:\workspace\openbravo目录
svn co https://dev.openbravo.com/svn/openbravo/trunkAppsOpenbravo
将得到最新的源代码
获得源代码后,进行如下操作:
d:\workspace\openbravo>ant setup
执行完成后会生成setup-properties-windows.exe文件,运行该文件。
导入项目
在导入项目前,一定要取消自动编译,因为刚刚导入的项目会有很多error,所以会浪费时间。
导入openbravo到eclipse中,选择File > Import... > Existing Projects into Workspace
选择目录d:\workspace\openbravo,接下来依次导入OpenbravoCore,OpenbravoTrl,OpenbravoWAD,分别在目录src-core, src-trl, src-wad.
设置所有项目的编码为UTF-8, 以避免乱码问题。
目前这些项目可能都有编译错误,不用管它,继续下面的操作。
d:\workspace\openbravo>ant create.database
Buildfile: build.xml
set.code.rev:
code.rev:
init:
core.lib:
init:
compile:
[javac] Compiling 122 source files to D:\workspace\openbravo\src-core\build\
classes
build.jar:
[jar] Building jar: D:\workspace\openbravo\src-core\lib\openbravo-core.jar
build:
copy.core.lib:
[copy] Copying 1 file to D:\workspace\openbravo\lib\runtime
database.lib:
init:
compile:
[javac] Compiling 4 source files to D:\workspace\openbravo\src-db\build\clas
ses
build.jar:
[jar] Building jar: D:\workspace\openbravo\src-db\build\lib\dbmanager.jar
jar:
[copy] Copying 1 file to D:\workspace\openbravo\src-db\database\lib
create.database:
create.database:
clean.database.POSTGRE:
[sql] Executing commands
[sql] Failed to execute: DROP DATABASE openbravo
[sql] org.postgresql.util.PSQLException: ERROR: database "openbravo" does
not exist
[sql] 0 of 1 SQL statements executed successfully
[sql] Executing commands
[sql] Failed to execute: DROP ROLE tad
[sql] org.postgresql.util.PSQLException: ERROR: role "tad" does not exist
[sql] 0 of 1 SQL statements executed successfully
prepare.database:
POSTGRE.structure:
[sql] Executing commands
[sql] 2 of 2 SQL statements executed successfully
[sql] Executing commands
[sql] 1 of 1 SQL statements executed successfully
create.database.all:
Database connection: jdbc:postgresql://localhost:5432/openbravo. User: tad
Executing default prescript
Executed 116 SQL command(s) successfully
Executing creation script
for the complete database
Executed 10739 SQL command(s) successfully
Executed 12 forced SQL command(s) successfully
Executing default postscript
Executed 22 SQL command(s) successfully
Writing checksum info
Inserting data into the database.
Executed 462 SQL command(s) successfully
Executed 2442 SQL command(s) successfully
Executed 74 SQL command(s) successfully
Executed 143 SQL command(s) successfully
Executed 5451 SQL command(s) successfully
Executed 462 SQL command(s) successfully
Executed 2442 SQL command(s) successfully
Executing default postscript
Executed 22 SQL command(s) successfully
database.poststructure.POSTGRE:
database.preimport.POSTGRE:
database.postimport.POSTGRE:
database.postcreate.POSTGRE:
[sql] Executing commands
[sql] 11 of 11 SQL statements executed successfully
update.dbupdate.timestamp:
[sql] Executing commands
[sql] 1 of 1 SQL statements executed successfully
db.apply.modules.sampledata:
BUILD SUCCESSFUL
Total time: 6 minutes 27 seconds
D:\workspace\openbravo>
接下来依次进行如下操作:
选择项目 Openbravo然后点击 Run > External Tools > eclipse.trl.lib
在 Console 窗口,确认有BUILD SUCCESSFUL 信息.
选择项目 Openbravo然后点击 Run > External Tools > eclipse.wad.lib
在 Console 窗口,确认有BUILD SUCCESSFUL 信息.
选择项目 Openbravo然后点击 Run > External Tools > eclipse.compile.complete
在 Console 窗口,确认有BUILD SUCCESSFUL 信息.
需要修改class的输出路径:openbravo/WebContent/WEB-INF/classes,这样才能在tomcat server中运行。
点击 Project > Build Project 菜单进行编译.
定义 Tomcat server
为了在eclipseIDE中运行OpenBravo,那么需要定义 Tomcat server.
点击 window > Preferences > Server > Runtime Enviroments > Add > 选择Apache tomcat 6.0 > 点next >选择你安装的tomcat目录和jre > 选择Openbravo项目 > 点击finish
双击打开添加的Tomcat Server > Server Locations一栏选择“Use custom location”,Server path文本框输入tomcat,Deploy path文本框输入webapps > 选中Serve modules without publishing > ctrl + s保存。
启动Tomcat server(该操作会持续大几分钟,耐心等待。)
选中创建的server,然后点击 start图标,或者右键 start。
启动完成后在浏览器中输入:http://localhost:8080/openbravo
用户名Openbravo
密码openbravo
恭喜你可以开始Openbravo之旅了。