Christian Wilkie Christian Wilkie - 4 years ago 92
Java Question

Can't find some MyBatis classes to import in getting started guide

I'm a beginner and haven't used MyBatis before and decided to start by working through the MyBatis getting started guide on the official Github site:

However, I ran into some trouble early on and I was hoping it is something simple that someone can help me with. Specifically, I'm stuck trying to do the example under the header "Building SqlSessionFactory without XML". The example is as follows:

If you prefer to directly build the configuration from Java, rather
than XML, or create your own configuration builder, MyBatis provides a
complete Configuration class that provides all of the same
configuration options as the XML file.

DataSource dataSource = BlogDataSourceFactory.getBlogDataSource();
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);

I then looked through the JavaDoc for the latest mybatis-3.2.5 release and couldn't find some of the classes I was looking for, like BlogDataSourceFactory and BlogMapper. Also, everything is under org.apache.ibatis when I would have expected it to be under org.mybatis (apparently ibatis is the old project name when it was maintained by Apache). I also checked the pre-release mybatis-3.2.6-SNAPSHOT but it had the same package structure and I still couldn't find those missing classes.

Sorry if this is a really dumb question/I'm missing something obvious, I'm not that experienced of a Java developer either and I appreciate any help!

Answer Source

Well, I'm not sure if I should delete this question, but basically the answer from maba in the comments seems to be right. I misinterpreted the documentation to mean that BlogMapper was an implemented example provided in the library, but that doesn't seem to be the case, and the implementation of it is left up to the reader.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download