ITeye博客

spring2.5

共 21 篇文章

<aop:aspectj-autoproxy />作用

通过配置织入@Aspect切面 虽然可以通过编程的方式织入切面,但是一般情况下,我们还是使用spring的配置自动完成创建代理织入切面的工作。通过aop命名空间的<aop:aspectj-autoproxy />声明自动为spring容器中那些配置@Aspect切面的bean创建代理,织入切面。当然,spring在内部依旧采用AnnotationAwareAspectJAutoProxyCreator进行自动代理的创建工作,但具体实现的细节已经被<aop:aspectj-autoproxy />隐藏起来了。 <aop:aspectj-autoproxy />有一个proxy-target-c…

2013-10-12 20:05 · spring2.5 · spring3.1 · springmvc

struts2、spring和hibernate整合时遇到的一些问题

1.Action对象的产生问题(struts2本身产生好呢?还是让spring代替struts2产生好呢?) 答:这个问题是关于struts2和spring的整合问题,需要用到struts2的struts2-spring-plugin.jar包 如果让struts2本身产生action,action中的set方法struts2会根据这个jar包自动注入(不需要通过@Resource手动注入),如果在set方法上通过@Resource手动注入的话,会起不到任何作用,除非在set方法对应的成员变量上通过@Resource手动注入。 如果让spring代替struts2产生action,这个时候就…

2013-09-21 22:58 · struts2 · hibernate · spring2.5

spring对hibernate的简单封装(hibernateDaoSupport)(xml/annotation)

bean.xml中添加: <!-- spring对hibernate的简单封装 --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> <bean id="userDAOImpl" class="com.test.dao.impl.UserDAOImpl"> <property name="hibernateTemplate" re…

2013-09-17 00:39 · spring2.5

spring对hibernate的简单封装(hibernateTemplate)

bean.xml中添加: <!-- spring对hibernate的简单封装 --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> 实现接口类 UserDAOImpl.java package com.test.dao.impl; import javax.annotation.Resource; import org.spri…

2013-09-16 00:24 · spring2.5

spring进行声明式事务管理(xml)(推荐,可以同时配置好多方法)

这里UserService.java中不用Transactional注解 UserService.java package com.test.service; import javax.annotation.Resource; import org.springframework.stereotype.Component; import com.test.dao.LogDAO; import com.test.dao.UserDAO; import com.test.model.Log; import com.test.model.User; @Component("userService"…

2013-09-15 18:14 · spring2.5

spring进行声明式事务管理(annotation)

在使用注解的时候,首先得在配置文件bean.xml中添加命名空间: xmlns:tx="http://www.springframework.org/schema/tx" 然后在xsi:schemaLocation中添加: http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 再次引入事务管理者: <tx:annotation-driven transaction-manager="txManager"/> bean.xml <?xml versi…

2013-09-15 11:02 · spring2.5

spring和hibernate初步整合(annotation)

bean.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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.s…

2013-09-15 01:26 · spring2.5

spring中dataSource的配置以及配合IOC的使用

bean.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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.s…

2013-09-14 19:02 · spring2.5

spring使用动态代理面向切面编程(AOP) xml

在使用注解的时候,首先得在配置文件bean.xml中添加命名空间: xmlns:aop="http://www.springframework.org/schema/aop" 然后在xsi:schemaLocation中添加: http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd bean.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springfra…

2013-09-14 17:51 · spring2.5

spring使用动态代理面向切面编程(AOP) annotation

在使用注解的时候,首先得在配置文件bean.xml中添加命名空间: xmlns:aop="http://www.springframework.org/schema/aop" 然后在xsi:schemaLocation中添加: http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 再次引入: <aop:aspectj-autoproxy/> bean.xml <?xml version="1.0" encoding="UTF-8"?> <be…

2013-09-14 13:31 · spring2.5

使用动态代理面向切面编程(AOP)

模型类 User.java package com.test.model; public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPasswor…

2013-09-14 01:50 · spring2.5

spring中Resource和Component注解

在使用注解的时候,首先得在配置文件bean.xml中添加命名空间: xmlns:context="http://www.springframework.org/schema/context" 然后在xsi:schemaLocation中添加: http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 再次引入: <context:component-scan base-package="com.test"></contex…

2013-09-12 19:26 · spring2.5

spring中Autowired和Qulifier注解

在使用注解的时候,首先得在配置文件bean.xml中添加命名空间: xmlns:context="http://www.springframework.org/schema/context" 然后在xsi:schemaLocation中添加: http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 再次引入: <context:annotation-config/> bean.xml <?xml version="1.0…

2013-09-12 19:23 · spring2.5

spring中service生命周期(xml/annotation)

1.xml 在配置文件 bean.xml中,bean标签通过配置属性init-method,可以在执行该bean的时候,首先执行该属性配置的方法,配置属性destroy-method,可以在执行完bean的时候,执行它配置的方法(代码中要显示调用destroy方法)。 bean.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" xsi…

2013-09-12 19:00 · spring2.5

spring自动装配

1.byName <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- 由于…

2013-09-12 00:11 · spring2.5

spring集合属性

在配置文件bean.xml中,配置bean的时候初始化属性的值: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring…

2013-09-11 23:37 · spring2.5

spring中bean的范围(xml/annotation)

1.xml 配置文件bean.xml中,bean标签中的属性scope默认为singleton,表示每次创建的service和首次创建的是同一个对象,如果设置为prototype,表示每次创建的service是不同的对象。 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.spri…

2013-09-11 23:27 · spring2.5

spring简单属性

在配置文件bean.xml中,配置bean的时候初始化属性的值: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring…

2013-09-11 23:25 · spring2.5

spring介绍(set和构造器注入)

1.实体类 User.java package com.test.model; public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassw…

2013-09-10 19:46 · spring2.5

spring简单模拟(面向抽象/接口编程)

1.实体类 User.java package com.test.model; public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassw…

2013-09-09 23:43 · spring2.5