惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 情义俩难全

PHPMAIL实例 使用shale实现jsf客户端验证(原创) ssh创建全过程 myeclipse 整合 jsf+spring2.0+hibernate3.0的问题 用myeclipse创建spring+hibernate工程时候的jar包冲突问题!!! netbeans6.5开发JSF+Hibernate的一个小例子(原创) JavaScript实现导出为Excel - 情义俩难全 - 博客园 配置 MyEclipse 的 WebLogic 9 服务器 jsp主次数据显示 jsp+javabean实现分页 浅谈“三层结构”原理与用意(转载) MySQL5.0中文问题及JDBC数据库连接和JSP汉字编码问题解决方法总结 用C#生成随机中文汉字验证码的基本原理 ASP.Net+XML打造留言薄 用ASP.NET部署三层架构 - 情义俩难全 - 博客园 .net环境下如何使用MySql数据库(原创) ASP与存储过程 - 情义俩难全 NBSI2内部功能实现大揭谜 存储过程入门与提高
MyEclipse6.0 整合 Spring2.0 , Strust2 ,Hibernate3.0 - 情义俩难全
情义俩难全 · 2009-04-19 · via 博客园 - 情义俩难全

MyEclipse6.0 整合 Spring2.0 , Strust2 ,Hibernate3.0

(1) 添加struts2支持

1.导入jar包
freemarker.jar,ognl.jar,struts2-core.jar,xwork.jar,需要注意的是,struts2-core.jarstruts2-all.jar不能共存。

2.添加struts.xml

3.修改web.xml

(2) 添加hibernate支持

1.先在MyEclipse Derby测试数据库连接成功后,然后添加hibernate支持。再切换到MyEclipse Database Explorer, 找到需要的表,右键选择Hibernate Reverse Engineering...,导入实体类以及与表相关联的xml即可。
如果手写,到网上找些Hibernate.cfg.xml,表关联的xml的配置更改一下,再导入jar包就行了。

(3) 添加spring支持

1.MyEclipse添加spring支持时,勾选常用的Spring 2.0 AOP,Spring 2.0 Core,Spring 2.0 Web

创建applicationContext.xml

(4) 整合spring,hibernate

1.修改数据源

a.采用spring的数据源,首先添加类库Spring 2.0 ORM/DAO/Hibernate3.0
数据提供类: org.springframework.jdbc.datasource.DriverManagerDataSource

  1. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource ">
  2.      <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
  3.      <property name="url" value="jdbc:mysql://localhost:3306/mysql?characterEncoding=gb2312">
  4.      </property>
  5.      <property name="username" value="root"></property>
  6.      <property name="password" value="sa"></property>
  7. </bean>

b.apache数据池,所需jar包,commons-dbcp.jar,commons-pool.jarcommons-collections.jar
数据提供类: org.apache.commons.dbcp.BasicDataSource

  1. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  2.      <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
  3.      <property name="url" value="jdbc:mysql://localhost:3306/mysql?characterEncoding=gb2312">
  4.      </property>
  5.      <property name="username" value="root"></property>
  6.      <property name="password" value="sa"></property>
  7. </bean>

c.JNDI数据池
数据提供类: org.springframework.jndi.JndiObjectFactoryBean

  1. <bean id="dataSource" class="org.springframework.indi.JndiObjectFactoryBean"> 
  2.      <property name="jndiName">
  3.          <value>jdbc/TestDB</value> 
  4.      </property>      
  5. </bean>

(5) 整合spring,struts2

1.导入struts2-spring-plugin.jar,struts2目录下可以找到

2.struts.xml 进行常量配置,交给spring管理

  1. <struts/>
  2.      <constant name="struts.objectFactory" value="spring" />
  3. <struts/>

3.web.xml 把监听权交给spring

  1. <listener/>
  2.      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  3. <listener/>

4.applicationContext.xml 里创建action对象

  1. <bean id="TestAction" class="com.lmj.web.action.TestAction">
  2.      <property name="tempDAO" ref="tempDAO"></property>
  3. </bean>

5.struts.xml 里创建action对象,name必须与applicationContext.xml里bean的id一致

  1. <action name="TestAction" class="com.lmj.web.action.TestAction">
  2.      <result>/service/welcome.jsp</result>
  3. </action>