基于oracle数据库的appfuse项目
一、环境
1、appfuse1.9.4
2. jdk1.5
3. tomcat5.5
4.ant 1.7
二、环境变量设置
JAVA_HOME=你的jdk安装目录,例如:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0
ANT_HOME=你下载解压后的Ant目录,例如:
ANT_HOME=F:\apache-ant-1.7.0
注意:要拷贝一个 junit.jar 到 %ANT_HOME%/lib 下,如果 lib 下没有 junit.jar,AppFuse 的脚本在运行时会给出警告信息。
CATALINA_HOME=你的Tomcat的安装目录,例如:
CATALINA_HOME=C:\Program Files\Apache Software Foundation\Tomcat 5.5
设置
-----------------------------------------------------------------------
PATH=%JAVA_HOME%/bin;%CATALINA_HOME%bin;%ANT_HOME%bin
-----------------------------------------------------------------------
三、appfuse目录下更改
1、把Oracle的JDBC驱动文件ojdbc14.jar,classes12.jar 复制到appfuse\lib\oracle目录下,oracle目录要新建
2、在Oracle中新增一个用户有两种
(1)直接打开Oracle新增一个用户,例如:ADMIN,权限最要少要有新增表的权限
(2)运行以下sql语句
CREATE USER ADMIN IDENTIFIED BY ADMIN;
GRANT CONNECT TO ADMIN;
GRANT RESOURCE TO ADMIN;
3、修改build.properties文件如下
database.jar=${lib.dir}/oracle/ojdbc14.jar
database.type=oracle
database.host=10.*.*.170
#use the database schema owner and password created in step #1 above here
database.username=edu
database.password=edu
database.schema=EDU
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
database.driver_class=oracle.jdbc.driver.OracleDriver
database.url=jdbc:oracle:thin:@10.*.*.170:1521:q1spc01
4、修改bulid.xml文件
<!=================================================================== -->
<!-- The "db-create" target creates a database based on properties -->
<!-- from the database.properties file -->
<!-- =================================================================== -->
<target name="db-create" depends="init"
description="create database for ${database.type}">
<echo level="debug">${database.jar}</echo>
<if>
<equals arg1="${database.type}" arg2="oracle"/>
<then>
<echo message="Detected Oracle, creating database..."/>
<echo>Creating '${database.name}' database with: ${database.type}-create.sql</echo>
<echo>URL: ${database.admin.url}</echo>
<copy tofile="${build.dir}/dao/gen/${database.type}-create.sql" overwrite="true" filtering="true">
<fileset file="metadata/sql/${database.type}-create.sql"/>
<filterset refid="db.variables"/>
</copy>
<sql onerror="continue"
<!--注意以下要与上面的bulid.properties文件的对应-->
driver="${database.driver_class}"
url="${database.url}"
userid="${database.username}"
password="${database.password}">
原来的有一句是url="${database.admin.url}"改成url="${database.url}"
看清楚了,这里花了我好长时间,要不能总是报Oracel用户名密码不对.
---------------------------------------------------------------------
注意还有一个地方要修改,也是在bulid.xml文件下
<!-- =================================================================== -->
<!-- Export the data -->
<!-- =================================================================== -->
<target name="db-export" depends="prepare"
description="Exports the current data in the database">
<dbunit driver="${database.driver_class}" url="${database.url}"
userid="${database.username}" password="${database.password}">
<export dest="db-export.xml" format="xml"/>
</dbunit>
</target>
<target name="db-load" depends="prepare" description="Loads the database with sample data">
<!-- Conditionally change operation based on whether database is mssql -->
<condition property="operation" value="MSSQL_CLEAN_INSERT" else="CLEAN_INSERT">
<equals arg1="${database.type}" arg2="sqlserver"/>
</condition>
<property name="file" value="metadata/sql/sample-data.xml"/>
<dbunit driver="${database.driver_class}"
supportBatchStatement="false" url="${database.url}"
-----------------------------------------------------------------------------
userid="${database.username}" password="${database.password}">
----------------------------------------------------------------------------
在这里要新增一个schema="${database.schema}变成以下语句
要不能会报"org.dbunit.database.AmbiguousTableNameException ."这个错
userid="${database.username}" password="${database.password}"
schema="${database.schema}">
4、在appfuse\metadata\sql目录新建一个文件
oracle-create.sql
文件里什么都不用写
------------------------------------------------
四、现在开始生成你的Oracle项目了
cd {appfuse path}
ant new -Dapp.name=myappname -Ddb.name=appftest
cd ..\myappname
ant setup
五、检验
启动tomcat
在浏览器敲入url:http://localhost:port/myappname检验是否成功!
posted on 2007-07-03 17:42
扭曲的铅笔 阅读(1232)
评论(2) 编辑 收藏 所属分类:
AppFuse