spring+ibatis+struts的一个小东西,出了个错,麻烦大家看看
先看网页上的错误信息吧:
javax.servlet.ServletException: Error creating bean with name 'managerFacade ' defined in class path resource [spring.xml]: Cannot resolve reference to bean 'managerImpl ' while setting bean property 'managerServiceImpl '; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'managerImpl ' defined in class path resource [spring.xml]: Cannot resolve reference to bean 'questionsDao ' while setting bean property 'questionsDao '; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'questionsDao ' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.webexam.dao.QuestionsDao]: Constructor threw exception; nested exception is com.ibatis.common.exception.NestedRuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap '. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/resultMap/result '. Cause: com.ibatis.common.exception.NestedRuntimeException: Error. Could not set TypeHandler. Cause: java.lang.ClassNotFoundException: String
Caused by: java.lang.ClassNotFoundException: String
上面的只是第一行。。。
我的spring.xml文件比较简单:
<bean id= "questionsDao "
class= "com.webexam.dao.QuestionsDao ">
</bean>
<bean id= "managerImpl " class= "com.webexam.Service.Manager.ManagerServiceImpl " singleton= "false ">
<property name= "questionsDao ">
<ref local= "questionsDao "> </ref>
</property>
</bean>
<bean id= "managerFacade " class= "com.webexam.Service.Manager.ManagerServiceFacade " singleton = "false ">
<property name = "managerServiceImpl ">
<ref local= "managerImpl "/>
</property>
</bean>
另外,ManagerServiceImpl和ManagerServiceFacade也比较简单,就是set/get方法:
ManagerServiceImpl文件:
public class ManagerServiceImpl {
private QuestionsDao questionsDao;
public QuestionsDao getQuestionsDao() {
return questionsDao;
}
public void setQuestionsDao(QuestionsDao questionsDao) {
this.questionsDao = questionsDao;
}
public int getQuestionsCount() throws Exception{
return questionsDao.getQuestionsCount();
}
}
ManagerServiceFacade文件:
public class ManagerServiceFacade {
private ManagerServiceImpl managerServiceImpl;
public ManagerServiceImpl getManagerServiceImpl() {
return managerServiceImpl;
}
public void setManagerServiceImpl(ManagerServiceImpl
managerServiceImpl) {
this.managerServiceImpl = managerServiceImpl;
}
}
就这些。
找了很多文章看了也没搞定这个问题,初学,多多指教。
[解决办法]
ClassNotFoundException
没有找到你的bean啊,应该是路径方面的问题,看看xml中的配置吧
[解决办法]
questionsDao生成的时候不需要任何注入吗?
questionsDao应该是访问数据库吧,至少应该有dataSource,sessionFactory
<bean id= "dataSource "
class= "org.springframework.jdbc.datasource.DriverManagerDataSource "
abstract= "false " singleton= "true " lazy-init= "default "
autowire= "default " dependency-check= "default ">
<property name= "driverClassName "
value= "com.microsoft.jdbc.sqlserver.SQLServerDriver ">
</property>
<property name= "url "
value= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=gwdhs ">
</property>
<property name= "username " value= "sa "> </property>
<property name= "password " value= " "> </property>
</bean>
<bean
class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean "
id= "sessionFactory " singleton= "true " abstract= "false "
autowire= "default " dependency-check= "default " lazy-init= "default ">
<property name= "dataSource ">
<ref bean= "dataSource " />
</property>
<property name= "hibernateProperties ">
<props>
<prop key= "hibernate.dialect ">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name= "mappingResources ">
<list>
<value> hibernate/po/GwdUser.hbm.xml </value>
</list>
</property>
</bean>
<bean id= "gwdCjDao " class= "hibernate.dao.GwdCjDaoImp ">
<property name= "sessionFactory ">
<ref bean= "sessionFactory "/>
</property>
</bean>
连sqlserver的,借鉴一下
[解决办法]
你的ibatis文件 好像也有错
[解决办法]
可以把typeAlias去掉试一下,呵呵
[解决办法]
ibatis配置文件中的resultMap配置有错~~
lz仔细检查一下