Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [config/mybatis/mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'java.util.String'.  Cause: java.lang.ClassNotFoundException: Cannot find class: java.util.String
applicationContext.xml里面的mybatis配置<!-- spring配置链接sqlSessionFactory  -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="configLocation" value="classpath:config/mybatis/mybatis-config.xml"/>  
        <property name="dataSource" ref="dataSource" />  
    </bean>  
    <!-- 
    <import resource="applicationContext-*.xml"/>
     -->
    
    <!-- 配置sqlSessionTemplate -->  
    <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">  
        <constructor-arg index="0" ref="sqlSessionFactory" />  
    </bean>  
    
    <!-- 由spring管理mybatis的事物 -->  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource"/>  
    </bean>    mybatis-config.xml里面配置
<typeAliases>  
        <typeAlias type="com.zhang.po.Student" alias="student" />  
    </typeAliases>  
  
    <!-- 定义映射资源 -->  
    <mappers>  
        <mapper resource="com/zhang/po/sqlMappers/StudentMapper.xml" />  
    </mappers>  
SpringMyBatisStruts

解决方案 »

  1.   

    StudentMapper.xml配置<mapper namespace="com.zhang.po.Student">  
    <!-- Mapper文件最好放在与Dao接口同一目录下 -->  
      
        <!-- 定义数据库字段与实体对象的映射关系 -->  
        <resultMap type="student" id="studentMap">  
            <id column="id" property="id" javaType="java.lang.String" jdbcType="VARCHAR" />  
            <result column="studentName" property="studentName" javaType="java.lang.String" jdbcType="VARCHAR" />  
            <result column="age" property="age" javaType="int" jdbcType="INTEGER" />  
            <result column="classes" property="classes" javaType="java.lang.String" jdbcType="VARCHAR" />  
            <result column="school" property="school" javaType="java.util.String" jdbcType="VARCHAR" />  
        </resultMap>  
      
        <!-- 定义要操作的SQL语句 -->  
      
        <insert id="save" parameterType="com.zhang.po.Student" useGeneratedKeys="true" keyProperty="id">  
            insert into  student(studentName,age,classes,school) values(#{studentName},#{age},#{classes},#{school})  
        </insert>  
      
        <update id="update" parameterType="com.zhang.po.Student">  
            update student set name=#{name},phone=#{phone},birthday=#{birthday}  where id=#{id}  
        </update>  
      
        <delete id="delete" parameterType="int">  
            delete from student where id=#{id}  
        </delete>  
      
        <select id="findById" parameterType="int" resultMap="studentMap">  
            select * from student where id=#{id}  
        </select>  
      
        <select id="findAll" resultMap="studentMap">  
            select *  from student  
        </select>  
          
    </mapper>