Problem with config XML file validation

161 views
Skip to first unread message

Aaron Baff

unread,
Mar 9, 2016, 3:09:26 PM3/9/16
to mybatis-user
So I'm very new to mybatis, and so far in my prototyping it looks very good, however when I try and add <settings> and <typeAliases> to the config.xml, it gives me:

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

Here's my mybatis-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
   
<environments default="development">
       
<environment id="development">
           
<transactionManager type="JDBC"/>
           
<dataSource type="POOLED">
               
<property name="driver" value="com.mysql.jdbc.Driver"/>
               
<property name="url" value="jdbc:mysql://test11:4001/jdo_test"/>
               
<property name="username" value="jdo-test"/>
               
<property name="password" value="testme123"/>
           
</dataSource>
       
</environment>
   
</environments>
   
<settings>
       
<setting name="useGeneratedKeys" value="true"/>
       
<setting name="autoMappingUnknownColumnBehavior" value="true"/>
       
<setting name="mapUnderscoreToCamelCase" value="true"/>
   
</settings>
   
<typeAliases>
       
<typeAlias type="com.findology.spring_testing.model.Advertiser" alias="Advertiser"/>
       
<typeAlias type="com.findology.spring_testing.model.Campaign" alias="Campaign"/>
   
</typeAliases>
   
<mappers>
       
<mapper class="com.findology.spring_testing.mapper.AdvertiserMapper"/>
       
<mapper class="com.findology.spring_testing.mapper.CampaignMapper"/>
   
</mappers>
</configuration>


Iwao AVE!

unread,
Mar 9, 2016, 8:10:16 PM3/9/16
to mybatis-user
Hi Aaron,

Try changing the order of the elements so that it matches the error message.

settings -> typeAliases -> environments - > mappers

Hope this helps,
Iwao
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mybatis-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Aaron Baff

unread,
Mar 15, 2016, 6:02:50 PM3/15/16
to mybatis-user
Sorry, wasn't checking this thread, for some reason it didn't auto-email me.

Yup, that worked just fine, thanks! Annoying though, since there's nothing documented about that order matters and typically the order of the top level entities in XML hasn't been a problem for other XML config files I've used.

--Aaron

Iwao AVE!

unread,
Mar 16, 2016, 10:15:27 AM3/16/16
to mybatis-user
Good to know that it worked!
I don't like it either. I am just used to the error ;-)

It might be a good reason for adopting .xsd in addition to .dtd if
it's possible to define order-less elements in .xsd.

Cheers,
Iwao
Reply all
Reply to author
Forward
0 new messages