SSH环境搭建,配置整合初步(一)
2014-04-28 15:02
495 查看
1,新Web工程,并把编码设为utf-8(所有的都是uft8数据库也是,就不会乱码了)
2,添加框架环境
Junit
Struts2
Hibernate
Spring
3,整合SSH
Struts2与Spring整合
Hibernate与Spring整合
4,资源分类
5,配置日志
Struts2
jar包
struts.xml, web.xml
Hibernate
jar包:核心包, 必须包, jpa, c3p0, jdbc
hibernate.cfg.xml, *.hbm.xml
Spring
jar包
appicationContext.xml/beans.xml
声明一个bean
(在bean/xml文件加入
<!-- 自动扫描与装配bean -->
<context:component-scan base-package="你的包名"></context:component-scan>)
@Component("beanName")
@Controller
@Service
@Repository
配置bean的scope
@Scope("prototype")
注入bean
@Resource
Spring与Struts2整合
1,在web.xml中配置Spring的监听器
2,加一个jar包
Hibernate与Spring整合
1,管理SessionFactory实例(只需要一个)
2,声明式事务管理
Spring
IOC 管理对象..
AOP 事务管理..
代码:
boolean needLog = ConfigFile.getBooleanValue("needLog");
if( needLog ){
System.out.println("xxx"); // System.err.println("");
}
配置文件(mylog.properties)
needLog = true/false
slf4j
JDK logging
--> logging.properties
Log4j --> log4j.properties
...
debug 调试信息
info 一般信息
warn 警告
error 错误
fatal 严重错误
================================================ 基本功能
User, UserDao
save(User user), update(), delete(), find(), ...
Role, RoleDao
save(Role role), update(), delete(), find(), ...
Student, StudentDao
save(Student student), update(), delete(), find(), ...
...
BaseDao<T>
save(T t), update(), delete(), find()
UserDao extends BaseDao<User> { ... }
RoleDao extends BaseDao<Role>{ ... }
...
2,添加框架环境
Junit
Struts2
Hibernate
Spring
3,整合SSH
Struts2与Spring整合
Hibernate与Spring整合
4,资源分类
5,配置日志
Struts2
jar包
struts.xml, web.xml
Hibernate
jar包:核心包, 必须包, jpa, c3p0, jdbc
hibernate.cfg.xml, *.hbm.xml
Spring
jar包
appicationContext.xml/beans.xml
声明一个bean
(在bean/xml文件加入
<!-- 自动扫描与装配bean -->
<context:component-scan base-package="你的包名"></context:component-scan>)
@Component("beanName")
@Controller
@Service
@Repository
配置bean的scope
@Scope("prototype")
注入bean
@Resource
Spring与Struts2整合
1,在web.xml中配置Spring的监听器
2,加一个jar包
Hibernate与Spring整合
1,管理SessionFactory实例(只需要一个)
2,声明式事务管理
Spring
IOC 管理对象..
AOP 事务管理..
代码:
boolean needLog = ConfigFile.getBooleanValue("needLog");
if( needLog ){
System.out.println("xxx"); // System.err.println("");
}
配置文件(mylog.properties)
needLog = true/false
slf4j
JDK logging
--> logging.properties
Log4j --> log4j.properties
...
debug 调试信息
info 一般信息
warn 警告
error 错误
fatal 严重错误
================================================ 基本功能
User, UserDao
save(User user), update(), delete(), find(), ...
Role, RoleDao
save(Role role), update(), delete(), find(), ...
Student, StudentDao
save(Student student), update(), delete(), find(), ...
...
BaseDao<T>
save(T t), update(), delete(), find()
UserDao extends BaseDao<User> { ... }
RoleDao extends BaseDao<Role>{ ... }
...
相关文章推荐
- MVC中DbContext 和ObjectContext两者的区别!
- Android 实例解说Application类
- 《算法导论》笔记 第16章 16.2 贪心策略的基本内容
- java Future用法和意义一句话击破
- centos6.4下安装memcached
- MVC批量添加,增加一条记录的同时添加N条集合属性所对应的个体
- LRU Cache
- mysql数据库存放路径
- 使用pdb调试python
- loadrunuer破解验证码
- Java快速判断是不是手机号
- error link 2019问题
- hive 配置参数说明
- Java快速判断是不是手机号
- linux 下 vi 命令使用
- 边沿触发
- 基于cocos2d开发的android小游戏——采花仙
- JAVA静态导入(inport static)详解
- 如何利用eclipse调试struts2的源码
- [LeetCode] Combinations