--
-- SqlMapConfig.xml
--
--
-- TestMyMapper.xml
--
--
-- TestMyMapper.java
--
package testmy.sqlmaps;
public interface TestMyMapper {
public String testMyBatisQuery();
}
--
-- RunTest.java
--
package testmy;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.session.TransactionIsolationLevel;
import testmy.sqlmaps.TestMyMapper;
public class RunTest {
public static void main(String[] args) throws Exception {
try(SqlSession session = new SqlSessionFactoryBuilder()
.build(Resources.getResourceAsReader("testmy/sqlmaps/SqlMapConfig.xml"))
.openSession(TransactionIsolationLevel.NONE)
) {
System.out.println(session.getMapper(TestMyMapper.class).testMyBatisQuery());
}
}
}
--
-- RunTest.bat file
--
@echo off
CD C:/test/testMyBatisBatch
:: Jar deployement blows up
::SET CPATH="MybatisCommandLine.jar"
:: exploded deployment works
SET CPATH="."
FOR /R ./lib %%a in (*.jar) DO CALL :AddToPath %%a
:: echo %CPATH%
java -cp %CPATH% testmy.RunTest
:AddToPath
SET CPATH=%1;%CPATH%
GOTO :EOF