我试图实现Spring MVC web-app(使用Spring-FW-ver:4.3.1)。我的网络应用程序的DAO层架构如下: -
//1. BaseDAO interface
public interface BaseDAO {
//abstract methods
}
//2. BaseDAOJdbcImpl.java file - an abstract DAO class for common method(s) which other sub-DAO classes can inherit
@Repository
public abstract class BaseDAOJdbcImpl extends NamedParameterJdbcDaoSupport implements BaseDAO
{
// implementations of above BaseDAO abstract methods
}
//3. UserDAO interface that extends BaseDAO interface
public interface UserDAO extends BaseDAO {
//abstract methods for User
}
//4. UserDAOJdbcImpl.java class file
@Repository
public class UserDAOJdbcImpl extends BaseDAOJdbcImpl implements UserDAO
{
// implementations of above UserDAO abstract methods
}
webapp-servlet.xml
Spring-MVC配置文件: -
.
.
<mvc:annotation-driven/>
<context:annotation-config/>
<context:component-scan base-package="springcrud"/>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/pmsDS"/>
</bean>
<bean id="baseDAOJdbcImpl" class="springcrud.dao.BaseDAOJdbcImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
.
.
我收到以下错误: -
java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required
dataSource
对象未被注入DAO层。上面的DAO层架构是有效的还是Spring配置的问题?