mybatis configuration 一些标签配置问题

18 篇文章 0 订阅

The content of element type "configuration" must match "(properties>settings>typeAliases>typeHandlers>objectFactory>objectWrapperFactory>plugins>environments>mappers?)".

(properties>settings>typeAliases>typeHandlers>objectFactory>objectWrapperFactory>plugins>environments>mappers

表示在configuration.xml中标签的顺序必须要按顺序写下来,按照上边的顺序依次向后排列书写。

 

其中对<typeAliases>标签的配置容易出现下列错误:

 

org.apache.ibatis.exceptions.PersistenceException:

### Error building SqlSession.

### The error may exist in SQL MapperConfiguration

### Cause:org.apache.ibatis.builder.BuilderException: Error parsing SQL MapperConfiguration. Cause: java.lang.NullPointerException

        org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)

    org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:54)

    org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:38)

        com.imooc.db.DBAccess.getSqlSession(DBAccess.java:21)

        com.imooc.dao.CommandDAO.queryCommandListByPage(CommandDAO.java:69)

        com.imooc.service.QueryService.queryCommandListByPage(QueryService.java:58)

        com.imooc.servlet.ListServlet.doGet(ListServlet.java:42)

        javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

        javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

 

configuration.xml中:

<configuration>

<typeAliases>
    <typeAlias alias="UserAlias" type="com.imooc.entity.Page"/>
  </typeAliases>


<plugins>
  <plugin interceptor="com.imooc.interceptor.PageInterceptor">
  <property name="test" value="abc"/>
  </plugin>
 </plugins>


  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC">
        <property name="" value=""/>
      </transactionManager>
      <dataSource type="UNPOOLED">
        <property name="driver" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message?"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
      </dataSource>
    </environment>
  </environments>
  
  <mappers>
    <mapper resource="com/imooc/config/sqlxml/Message.xml"/>
    <mapper resource="com/imooc/config/sqlxml/CommandContent.xml"/>
    <mapper resource="com/imooc/config/sqlxml/Command.xml"/>
  </mappers>


</configuration>

command.xml中:resultType="UserAlias"与configuration.xml中alias别名相对应

<select id="queryCommandListByPage" parameterType="java.util.Map"  resultMap="CommandResult" resultType="UserAlias">
  select ID,CONAME,DESCRIPTION from COMMAND
    <where>
    <if test="command.coname != null and !&quot;&quot;.equals(command.coname.trim())">
    and CONAME=#{command.coname}
   </if>
   <if test="command.description != null and !&quot;&quot;.equals(command.description.trim())">
    and DESCRIPTION like '%' #{command.description} '%'
   </if>
    </where>
    order by ID
 </select>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值