MyEclipse2014新建Web Project并配置SSH

环境:

myeclipse2014

win10

jdk1.7

tomcat8


1、创建一个web项目,FileNewWeb Project,设置如下:

finish项目新建完成

2、添加spring,右击项目名称选择:MyEclipseProject Facts [Capabilities]Install Spring Facet,如下:

3、添加hibernate,首先需要创建数据库连接,然后再添加Hibernate。此处以mysql为例

首先打开Database Explorer视窗:

新建连接

设置好后点击:Test Driver,测试成功显示:

next

新建成功,现在可以连接:

现在可以打开对应方案的表和视图等:

添加Hibernate,右击项目名称选择:MyEclipseProject Facts [Capabilities]Install Hibernate Facet,如下:

4、添加struts,右击项目名称选择:MyEclipseProject Facts [Capabilities]Install Apache Struts(2.x) Facet,如下:

SSH搭建完成:

发布网站,测试成功:






可能我们会用到自己下载的jar包,所以可以将下面几个jar包移除




在src创建hibernate.cfg.xml

内容如下

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

	<session-factory>
		<property name="dialect">
			org.hibernate.dialect.MySQLDialect
		</property>
		<property name="connection.url">
			jdbc:mysql://localhost:3306/sshtest
		</property>
		<property name="connection.username">root</property>
		<property name="connection.driver_class">
			com.mysql.jdbc.Driver
		</property>
		<property name="myeclipse.connection.profile">mysql</property>

	</session-factory>

</hibernate-configuration>


修改applicationContext.xml

内容如下

<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

<!--指明hibernate配置文件的位置  -->
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
  
</beans>


这样修改后,部署运行,能够正常运行



  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值