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 !"".equals(command.coname.trim())">
and CONAME=#{command.coname}
</if>
<if test="command.description != null and !"".equals(command.description.trim())">
and DESCRIPTION like '%' #{command.description} '%'
</if>
</where>
order by ID
</select>