Myeclipse搭建SSH框架的Web项目

📅 2026-02-03 01:51:28 ✍️ admin 👁️ 4173 ❤️ 315
Myeclipse搭建SSH框架的Web项目

1.新建web项目

2.引入strust2框架包和依赖文件

右击项目,Config Facets -> Instal Apache Struts(2X) Facets

3.添加spring依赖包和配置文件

a、方法和添加struts2相同

b、编辑/src/applicationContext.xml配置文件

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

value="classpath:hibernate.cfg.xml">

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

proxy-target-class="true" />

scope="prototype">

<!--hinernate层数据库操作类定义-->

4.建立数据库类连接,并将数据库表结构反转,自动生成对应pojo类

windows -> show view -> other -> DB Brower

右击Myeclipse Derby 新建连接,填写oracle连接数据(以oracle为例,其他数据库也类似),并导入oracle所依赖的包

5、导入hibernate包和配置文件

下图警告Hibernate版本不同时,要back回上一步,修改hibernate版本

6.利用myclipse使数据库类自动生成对象类和hibernate所需类配置文件

打开新建好的数据库连接,找到对应的用户名下的Table->表名->右击

ps:下列涉及的native:为主键生成方式(自动生成),其他生成方式请自行百度

最后会在项目中生成Users.java 和 Users.hbm.xml文件

大功告成!