J2EE环境搭建感悟
2015-11-21 11:26
309 查看
1、总体上先分层
a、src(默认的)b、config(配置文件)c、test(测试用)d、WebRoot下的css、images、js、pages、upload等。
2、加入框架
a、先加入spring支持。b、随后hibernate及struts支持
其中a中,spring框架加入后,首先,加入show_sql,format_sql。如
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
<prop key="hibernate.format_sql">
true
</prop>
</props>
</property>
其次、加入hibernate模板类。
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
3、加入公共页面如error.jsp等等。
4、为src分层如:dao,service,action,utils等级目录。又可以再分为前后端。
5、为config(配置文件)分层,包括hibernate,spring,struts等目录,在spring目录下加入例如applicationContext-transaction.xml等文件;在struts配置下加入struts.xml等文件;在hibernate文件下加入生成pojo的.hbm.xml类型文件;加入log4j。
6、web.xml中加入监听
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
7、导入数据库连接jar包
8、重启服务器,测试,如果看到控制台spring,hibernate,struts信息正常,没报错,证明环境搭建成功!
a、src(默认的)b、config(配置文件)c、test(测试用)d、WebRoot下的css、images、js、pages、upload等。
2、加入框架
a、先加入spring支持。b、随后hibernate及struts支持
其中a中,spring框架加入后,首先,加入show_sql,format_sql。如
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
<prop key="hibernate.format_sql">
true
</prop>
</props>
</property>
其次、加入hibernate模板类。
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
3、加入公共页面如error.jsp等等。
4、为src分层如:dao,service,action,utils等级目录。又可以再分为前后端。
5、为config(配置文件)分层,包括hibernate,spring,struts等目录,在spring目录下加入例如applicationContext-transaction.xml等文件;在struts配置下加入struts.xml等文件;在hibernate文件下加入生成pojo的.hbm.xml类型文件;加入log4j。
6、web.xml中加入监听
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
7、导入数据库连接jar包
8、重启服务器,测试,如果看到控制台spring,hibernate,struts信息正常,没报错,证明环境搭建成功!
相关文章推荐
- Codeforces Round #332 (Div. 2) C. Day at the Beach
- 先序遍历,中序遍历,后序遍历中如何知道两者求整棵树
- MyEclipse new 后面的菜单选项设置
- ViewController的页面跳转
- 利用touches方法拖动视图移动
- webrtc ICE rfc5245笔记
- sublime 设置缩进
- 一天当中最好的洗头时间
- 半平面求交——点在凸包外
- Pillow依赖库安装
- introduction to computer vision
- 自动生成项目的Makefile文件
- 轻松学习C#的预定义数据类型
- FTGL在OpenGL下显示中文
- 解析html 生成word文档
- ngxin proxy_set_header Host X-Forwarded-For
- 图片数组形成动画(UIImageView)
- Zookeeper 注册中心解析
- Unreal Engine 4 蓝图脚本学习 添加输入映射----实现冲刺和望眼镜效果 (3)
- RF Test and Measurement-1