在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java/ ssm中報(bào)這個(gè)錯(cuò)誤,該怎么解決!

ssm中報(bào)這個(gè)錯(cuò)誤,該怎么解決!

Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [G:通州學(xué)習(xí)java學(xué)習(xí).metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsssmWEB-INFclassesmapperAdminDaoImpl.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Admin'. Cause: java.lang.ClassNotFoundException: Cannot find class: Admin

回答
編輯回答
詆毀你
Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [G:通州學(xué)習(xí)java學(xué)習(xí).metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsssmWEB-INFclassesmapperAdminDaoImpl.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Admin'. Cause: java.lang.ClassNotFoundException: Cannot find class: Admin

看異常棧需要抓重點(diǎn),
那么你的錯(cuò)誤重點(diǎn)在于最后一句

: Could not resolve type alias 'Admin'. Cause: java.lang.ClassNotFoundException: Cannot find class: Admin

應(yīng)該是你的mapper使用了 Admin 而不是包名+Admin
解決方案 兩種
1、
將AdminDaoImpl.xml 中所有的Admin改成包名+Admin
2、
新建mybatis-config.xml
配置別名

<configuration>  
  <typeAliases>  
      <typeAlias type="包名.Admin" alias="Admin"/>  
  </typeAliases>  
</configuration>  

在spring-mybatis.xml 引入mybatis配置

     <!-- 配置mybatis的sqlSessionFactory -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!-- 自動(dòng)掃描mapper.xml文件-->
        <property name="mapperLocations" value="classpath:mapper/*.xml"/>
        <!-- 載入mybatis全局配置文件-->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
    </bean>

最后,編碼不易 望采納。

2018年9月15日 13:03