Aquaxu
2010-08-19 14:28
浏览 186
已采纳

struts2 srping ibatis 搭建的环境编译错误

找了2天都没查出是什么问题,到底是什么原因啊,有人知道吗?
谁能教教我,不胜感激。。。
下面是错误信息:

严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [com.smop.service.impl.UserServiceImpl]: Bean property 'userDao' is not writable or has an invalid setter method. Did you mean 'userDAO'?

[b]appliactionContext.xml[/b]
[code="xml"]
<?xml version="1.0" encoding="UTF-8"?>
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.0.xsd">

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName"
        value="oracle.jdbc.OracleDriver">
    </property>
    <property name="url" value="jdbc:oracle:thin:@192.168.1.1:1521:TESTDB"></property>
    <property name="username" value="admin"></property>
    <property name="password" value="123456"></property>
</bean>

<!-- SqlMap setup for iBATIS Database Layer -->  
<bean id="sqlMapClient"  
    class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">  
    <property name="configLocation"  
        value="WEB-INF/classes/sqlMapConfig.xml" />  
    <property name="dataSource" 
              ref="dataSource" >
    </property>
</bean>  

<!-- Transaction manager for a single JDBC dataSource -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
</bean>

<!--========================== DAO =============================-->
<bean id="userDao" class="com.smop.dao.impl.UserDaoImpl">
    <property name="sqlMapClient">
        <ref bean="sqlMapClient" />
    </property>
</bean>

<!--========================== Service =============================-->
<bean id="userService"
    class="com.smop.service.impl.UserServiceImpl">
    <property name="userDao" ref="userDao"></property>
</bean>

<!--========================== user Action =============================-->
<bean id="loginAction" class="com.smop.action.user.LoginAction">
    <property name="Service" ref="userService"></property>
</bean>


[/code]

[b]UserDao.java[/b]
[code="java"]
package com.smop.dao.impl;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.smop.dao.UserDao;
import com.smop.pojo.User;

public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {

public User findUserById(int id) throws RuntimeException {
    return (User) this.getSqlMapClientTemplate().queryForObject(
            "findUserById", id);
}

}
[/code]

[b]UserDaoImpl.java[/b]
[code="java"]
package com.smop.dao.impl;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.smop.dao.UserDao;
import com.smop.pojo.User;

public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {

public User findUserById(int id) throws RuntimeException {
    return (User) this.getSqlMapClientTemplate().queryForObject(
            "findUserById", id);
}

}
[/code]

[b]UserService.java[/b]
[code="java"]
package com.smop.service;

import com.smop.pojo.User;

public interface UserService {
public User getUserById(int id) throws RuntimeException;

}
[/code]

[b]UserServiceImpl.java[/b]
[code="java"]
package com.smop.service.impl;

import com.smop.dao.UserDao;
import com.smop.pojo.User;
import com.smop.service.UserService;

public class UserServiceImpl implements UserService {
private UserDao userDAO;

public UserDao getUserDAO() {
    return userDAO;
}

public void setUserDAO(UserDao userDAO) {
    this.userDAO = userDAO;
}

public User getUserById(int id) throws RuntimeException {
    return this.userDAO.findUserById(id);
}

}
[/code]

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题