ssh2环境配置Word格式.docx
《ssh2环境配置Word格式.docx》由会员分享,可在线阅读,更多相关《ssh2环境配置Word格式.docx(13页珍藏版)》请在冰豆网上搜索。
Buildfile:
build.xmldoesnotexist!
),而不是出现诸如命令无法解释的错误,那么你的ant就安装成功了
2.3Ant的配置文件build.xml
Ant的运行,靠的是一个构建脚本,默认的名称叫build.xml,如果你在任何目录下运行ant命令,Ant将自动查找当前目录下有没有build.xml文件,如果有这个文件,就读取这个文件,并运行其中的默认target。
二、SSH环境配置
1.xdoclet安装和配置
Xdoclet不是单独可以运行的工具(不像Ant工具),它可以与其它工具一起配合运行,如Ant。
1)首先需要保证ant是可用的
2)下载并解压xdoclet的包(我们现在使用的是xdoclet2,具体版本是xdoclet-plugins-1.0.3)。
3)在ant构建工具中定义xdoclet任务,并使用:
1.Tomcat部署
2.Hibernate开发环境配置过程
2.1Hibernate开发包下载:
2.2添加Hibernate的JAR包,将Hibernate安装包中的Hibernate2.jar文件和lib下的所有文件拷贝到项目的lib子目录下(或者将这些JAR直接拷贝到项目的lib目录,系统会自动将JAR拷贝到项目的lib目录下的)。
并将lib下的所有JAR设置到当前项目的环境变量中。
2.3在lib中添加JDBOfororacle数据库驱动程序
2.4在src目录中添加hibernate.cfg.xml文件,用于配置hibernate登录信息。
在HibernateConfguratoneditor中配置hibernate.cfg.xml各种参数和映射。
<
?
xmlversion="
1.0"
encoding="
ISO-8859-1"
>
!
DOCTYPEhibernate-configurationPUBLIC"
-//Hibernate/HibernateConfigurationDTD3.0//EN"
"
hibernate-configuration>
session-factory>
<
propertyname="
myeclipse.connection.profile"
Dome<
/property>
connection.url"
jdbc:
oracle:
thin:
@sserver:
1521:
sserver<
connection.username"
dynamolu<
connection.password"
11788150<
connection.driver_class"
oracle.jdbc.driver.OracleDriver<
dialect"
org.hibernate.dialect.Oracle9Dialect<
hibernate.show_sql"
true<
hibernate.hbm2ddl.auto"
update<
/session-factory>
/hibernate-configuration>
2.5根据数据库中的表编写映射文件和持久类文件,我们可以使用Myeclipse中Datebaseexplorer来自动生成映射文件和持久类。
此外还有其他工具可以用来生成这些文件。
2.5.1首先先在MyeclipseDatebaseexplorer连接数据库并测试是否连通oracle数据库,oracle驱动我们已经添加。
添加<
nature>
com.genuitec.eclipse.hibernate.hibernatenature<
/nature>
到.project中
重启Myeclipse。
3Struts2配置
3.1Struts2下载http:
//struts.apache.org/download.cgi#struts2181
3.2添加Struts2的jar包到项目的lib中。
3.3添加对Log4j的支持
3.4添加Struts2配置文件struts.properties和struts.xml在src目录下。
下载地址为
4spring配置
1)Spring下载
//www.springsource.org/download
2)添加jar包和TLD文件
3)添加spring监听器,让Spring能够控制应用。
在web.Xml进行
context-param>
param-name>
contextConfigLocation<
/param-name>
param-value>
/WEB-INF/applicationContext.xml<
/param-value>
/context-param>
listener>
listener-class>
org.springframework.web.context.ContextLoaderListener
/listener-class>
/listener>
4)添加spring编码过滤器
filter>
filter-name>
SetCharacterEncoding<
/filter-name>
filter-class>
org.springframework.web.filter.CharacterEncodingFilter
/filter-class>
<
init-param>
<
encoding<
UTF-8<
/init-param>
/filter>
filter-mapping>
url-pattern>
/*<
/url-pattern>
/filter-mapping>
cleanup<
org.apache.Struts2.dispatcher.ActionContextCleanUp
5)将Hibernate托管给spring
5.1将Hibernate中的DAO类和Server类在applicationContext中配置
方法如下
beanid="
moduleTypeAction"
class="
com.gxhos.struts2.action.SysModuleTypeAction"
scope="
prototype"
sysModuleTypeService"
ref="
/bean>
5)将Struts2托管给spring
在struts.xml中配置
actionname="
acl"
aclAction"
resultname="
success"
/sysmanager/acl_index.jsp<
/result>
/action>
在applicationContext----》spring接收Action托管
moduleAction"
com.gxhos.struts2.action.SysModuleAction"
moduleService"
6)处理Action,删除构造函数,添加getter/setter