2.5的吗? 好像有篇文章,http://www.ibm.com/developerworks/cn/java/j-lo-spring25-ioc/
使用 Spring 2.5 注释驱动的 IoC 功能
http://www.blogjava.net/beansoft/archive/2007/11/30/164230.html
Spring 2.5 标注开发的简单例子 http://www.ibm.com/developerworks/cn/opensource/os-lightweight3/
轻量级开发的成功秘诀,第 3 部分: Spring 露出水面你找找
使用 Spring 2.5 注释驱动的 IoC 功能
http://www.blogjava.net/beansoft/archive/2007/11/30/164230.html
Spring 2.5 标注开发的简单例子 http://www.ibm.com/developerworks/cn/opensource/os-lightweight3/
轻量级开发的成功秘诀,第 3 部分: Spring 露出水面你找找
解决方案 »
- 大家讨论一下InetAddress.getByAddress
- java连接access 为什么insert不好用?????
- lazy默认是false还是true啊
- 同一事务 是否能级联插入
- 最近在研究url rewrite技术,大家有没有例子,给一个参考一下,多谢了
- 高分相送----以Xfire方式开发WebService(用过的高手介绍下!!!!!!!!!!!)
- logback比log4j性能还低?
- 使用HttpClient如何保持会话,在多用户间切换
- 本人想学J2EE,不知道是用JBuilder还是用Eclipse
- 有关取EJB Home接口的疑问,望大侠们诠释一下,100分相送啊。
- 去掉eclipse注释中的警告语句
- apache 和tomcat 的问题
spring2.5注入支持annotation方式,只需要在配置文件中,写如下内容
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:component-scan base-package="com.aaa.bbb">
<!--想用spring管理哪个包下的类,就在这里加进来-->
<context:include-filter type="aspectj" expression="com.aaa.bbb.service..*"/>
<context:include-filter type="aspectj" expression="com.aaa.bbb.entity..*"/>
<!--想不让spring初始化就浏览的类,就在这里滤掉-->
<context:exclude-filter type="aspectj" expression="com.aaa.bbb.action..*"/>
</context:component-scan>
</beans>只加入上述方法还是不行的,还要在类中显示的声明annotatino,比如
package com.aaa.bbb.service;
import org.springframework.stereotype.Component;@Component("bean2")
public class TestBean2 {
public String getString(){
return "bean2";
}
}
这样的话就可以
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
bean2 = (TestBean2) ctx.getBean("bean2");以上只是一个简单的开发过程,像楼主说的某一个package下的类全部默认注入,而不用写什么东西,似乎还做不到,详细的还请参看spring2.5中文开发文档