1.用maven 创建项目(俺 用netbeans).
2.在pom.xml添加和修改.
dependencies:
<dependencies>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>3.0-beta-2</version>
</dependency>
<!-- others -->
</dependencies>
增加一个plugin, 支持java5
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
3.在src\main\resources下创建sqlmapconfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
<configuration>
<properties resource="blog-hsqldb.properties">
</properties>
<typeAliases>
<typeAlias type="com.yy.ibatis.Blog" alias="Blog" />
</typeAliases>
<plugins>
<plugin interceptor="com.yy.ibatis.BlogInterceptor">
<property name="key" value="ABCD" />
<property name="key2" value="CDEF" />
</plugin>
</plugins>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="map/BlogMapper.xml"/>
</mappers>
</configuration>
创建blog-hsqldb.properties文件
driver=org.hsqldb.jdbcDriver
url=jdbc:hsqldb:testdb
username=sa
password=
创建log4j.properties配置文件
log4j.rootLogger=DEBUG, stdout
### Uncomment ALL for iBATIS logging
log4j.logger.org.apache.ibatis=DEBUG
log4j.logger.java.sql=DEBUG
### For Testing
log4j.logger.java.lang.Object=DEBUG
### Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
4.定义map文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.yy.ibatis.BlogMapper">
<!-- 命名空间主要用来区分,并且,如果此名字同时时也是一个接口的完整名字的话,那么.... -->
<select id="selectBlog" parameterType="int" resultType="Blog">
select * from Blog where id = #{id}
</select>
</mapper>
分享到:
相关推荐
This abates some of the initial nuisance of setting up objects and configuration files to interact with database tables. Ibator seeks to make a major impact on the large percentage of database ...
将IBatis.NET 1.92 1.6.2版本的库在.NET 4.0下应用。结果发现总是报错Ambiguous match found 经过参考资料,重新整理了ibatis的资料,原因如下: iBatis中使用了Castle.DynamicProxy 1.5 而Castle.DynamicProxy ...
│ Simple3Formatter.java │ SimpleFormatter.java │ SocketHandler.java │ StreamHandler.java │ Test.java │ XMLFormatter.java │ ├─Android快速开发不可或缺的11个辅助类 │ AppUtils.java │ ...
详细说明:自动根据数据库脚本生成java的POJO,DAO,DAOIMPL,IBATIS配置文件,spring配置文件-Database scripts automatically generate java POJO, DAO, DAOIMPL, IBATIS configuration file, spring configuration ...
This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. MBG seeks to make a major impact on the large percentage of database operations that ...
1.Configuration.xml 是 mybatis 用来建立 sessionFactory 用的,里面主要包含了数据库连接相关东西,还有 java 类所对应的别名,比如 <typeAlias alias="User" type="com.yihaomen.mybatis.model.User"/> 这个别名...
Jar package source code, there is not much configuration is simple the spring + Ibatis + struts project
nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not ...
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl global-config: db-config: id-type: assign_id update-strategy: not_empty mapper-locations: classpath*:/mapper/*.xml ./configure \ --pr
13.11. 惯例优先原则(convention over configuration) 13.11.1. 对控制器的支持: ControllerClassNameHandlerMapping 13.11.2. 对模型的支持:ModelMap (ModelAndView) 13.11.3. 对视图的支持: ...
.3. 任务规划 2.6.4. 对Java 5(Tiger)的支持 2.7. 移植到Spring 2.0 2.7.1. 一些变化 2.7.1.1. Jar包 2.7.1.2. XML配置 2.7.1.3. Deprecated的类和方法 2.7.1.4. Apache OJB 2.7.1.5. iBatis 2.8. 更新的样例应用...
This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. MBG seeks to make a major impact on the large percentage of database operations that ...
13.11. 惯例优先原则(convention over configuration) 13.11.1. 对控制器的支持: ControllerClassNameHandlerMapping 13.11.2. 对模型的支持:ModelMap (ModelAndView) 13.11.3. 对视图的支持: ...
mybatis也能方向生成代码,能方向生成实体类(po)、mapper接口和Mapper接口映射文件,能减少...4、右击generatorConfig.xml 点击Generate MyBatis/iBATIS Artifacts 生成对应接口、接口映射文件、实体类 5、查看结果
13.11. 惯例优先原则(convention over configuration) 13.11.1. 对控制器的支持:ControllerClassNameHandlerMapping 13.11.2. 对模型的支持:ModelMap(ModelAndView) 13.11.3. 对视图的支持:...
13.11. 惯例优先原则(convention over configuration) 13.11.1. 对控制器的支持:ControllerClassNameHandlerMapping 13.11.2. 对模型的支持:ModelMap(ModelAndView) 13.11.3. 对视图的支持:...
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 99; columnNumber: 17; 元素类型为 “configuration” 的内容...