求助:spring的依赖注入配置问题

lxh1962 2011-10-03 10:05:49
初学srping ,请不吝赐教,谢过!!

spring-context.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.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:jbpm" />
<property name="user" value="jbpm" />
<property name="password" value="jbpm" />
<property name="maxPoolSize" value="40" />
<property name="minPoolSize" value="1" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="20" />

</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources" >
<list>
<value>com/easyweb/core/module/User.hbm.xml </value>
<value>com/easyweb/core/module/Role.hbm.xml </value>
</list>
</property>
</bean>

<import resource="app-action.xml" />
<import resource="app-security.xml" />
</beans>

app-action.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<context:annotation-config />

<bean id="udi" class="com.easyweb.core.dao.impl.UserImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="userAction" class="com.easyweb.core.action.UserAction">
<property name="ud" ref="udi"></property>
</bean>
<bean id="rdi" class="com.easyweb.core.dao.impl.RoleImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="roleAction" class="com.easyweb.core.action.RoleAction">
<property name="rd" ref="rdi"></property>
</bean>

</beans>
系统启动报错,初始化不成功,在udi装载时,要求datasouces或jdbctemplete
这里,udi的配置用到了sessionFactory,而sessionFactory的配置有datasource
以上配置有什么不对?
这种情部该如何配置?
...全文
212 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxh1962 2011-10-05
  • 打赏
  • 举报
回复
补充信息:udi的相关定义
@Transactional
public class UserImpl extends JdbcDaoSupport implements UserDao {
@Resource
private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}

public SessionFactory getSessionFactory() {
return sessionFactory;
}

错误信息如下:
Error creating bean with name 'udi' defined in class path resource [config/app-action.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required

Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧