2929
3030 <p >
3131 <span class =" label important" >NOTE</span >
32- See <a href =" https://github.com/mybatis/jpetstore-6" >JPetstore 6 demo</a > to know about how to use Spring with a full web application server. .
32+ 点击 <a href =" https://github.com/mybatis/jpetstore-6" >JPetstore 6 demo</a > 获取更多关于 Spring 在完整的应用服务器上面的使用例子. .
3333 </p >
3434
3535 <p >
36- You can check out sample code from the MyBatis-Spring <a href =" https://github.com/mybatis/spring/tree/master/src/test/java/org/mybatis/spring/sample" >repo</a >:
36+ 您可以从此处查看 MyBatis-Spring 的示例代码 <a href =" https://github.com/mybatis/spring/tree/master/src/test/java/org/mybatis/spring/sample" >repo</a >:
3737 </p >
3838 <p >
39- Any of the samples can be run with JUnit 4 .
39+ 任何一个示例都可以JUnit 4运行 .
4040 </p >
4141 <p >
42- The sample code shows a typical design where a transactional service gets domain objects from a data access layer .
42+ 示例代码显示了事务服务从数据访问层获取域对象的典型设计 .
4343 </p >
4444 <p >
45- <code >FooService.java</code > acts as the service :
45+ <code >FooService.java</code > 作为服务 :
4646 </p >
4747 <source ><![CDATA[
4848@Transactional
@@ -61,18 +61,10 @@ public class FooService {
6161}
6262]]> </source >
6363 <p >
64- It is a transactional bean, so a transaction is started when any of its methods is called
65- and committed when the method ends without throwing an unchecked exception.
66- Notice that transactional behaviour is configured with the
67- <code >@Transactional</code >
68- attribute. This is not required; any other way provided by Spring can be used to demarcate
69- your transactions.
64+ 它是一个事务bean,所以当调用它的任何方法时,事务被启动并且在方法结束时提交,且不会抛出未经检查的异常.请注意,事务行为配置为 <code >@Transactional</code > 属性. 这不是必需的 Spring 提供的任何其他方式都可用于划分你的事务.
7065 </p >
7166 <p >
72- This service calls a data access layer built with MyBatis. This layer
73- consists on a just an interface <code >UserMapper.java</code >
74- that will be used with a dynamic proxy built by MyBatis at
75- runtime and injected into the service by Spring.
67+ 此服务调用使用 MyBatis 构建的数据访问层. 这层只是一个界面 <code >UserMapper.java</code > 这将与 MyBatis 建立的动态代理一起使用运行时并通过 Spring 注入服务.
7668 </p >
7769 <source ><![CDATA[
7870public interface UserMapper {
@@ -82,19 +74,17 @@ public interface UserMapper {
8274}
8375]]> </source >
8476 <p >
85- Note that, for the sake of simplicity we used the interface <code >UserMapper.java</code > for the DAO scenario
86- where a DAO is built with an interface and a implementation though in this case it would have been more
87- adequate to use an interface called <code >UserDao.java</code > instead.
77+ 注意,为了简单起见,我们使用了接口 <code >UserMapper.java</code > 对于DAO场景其中一个DAO是用接口和一个实现构建的,尽管在这种情况下它将会更多足够使用一个接口调用 <code >UserDao.java</code > 来取代.
8878 </p >
8979 <p >
90- We will see different ways to find the mapper interface, register it to Spring and inject it into the service bean:
80+ 我们将看到不同的方法来找到映射器接口,将其注册到 Spring 并将其注入到服务 bean 中 :
9181 </p >
9282 <table >
93- <caption >Scenarios </caption >
83+ <caption >使用场景 </caption >
9484 <thead >
9585 <tr >
96- <th >Sample test </th >
97- <th >Description </th >
86+ <th >测试用样例 </th >
87+ <th >描述 </th >
9888 </tr >
9989 </thead >
10090 <tbody >
@@ -103,56 +93,53 @@ public interface UserMapper {
10393 <code >SampleMapperTest.java</code >
10494 </td >
10595 <td >
106- Shows you the base configuration based on a <code >MapperFactoryBean</code >
107- that will dynamically build an implementation for <code >UserMapper</code >
96+ 显示基于 <code >MapperFactoryBean</code > 的基本配置,这将动态构建一个实现 <code >UserMapper</code >
10897 </td >
10998 </tr >
11099 <tr >
111100 <td >
112101 <code >SampleScannerTest.java</code >
113102 </td >
114103 <td >
115- Shows how to use the <code >MapperScannerConfigurer</code > so all the mappers in a project are autodiscovered .
104+ 显示如何使用 <code >MapperScannerConfigurer</code > 来实现项目总所有 mappers 的自动发现 .
116105 </td >
117106 </tr >
118107 <tr >
119108 <td >
120109 <code >SampleSqlSessionTest.java</code >
121110 </td >
122111 <td >
123- Shows how to hand code a DAO using a Spring managed <code >SqlSession</code >
124- and providing your own implementation <code >UserDaoImpl.java</code >.
112+ 显示如何使用 Spring <code >SqlSession</code > 手动编写 DAO 并提供你自己的实现 <code >UserDaoImpl.java</code >.
125113 </td >
126114 </tr >
127115 <tr >
128116 <td >
129117 <code >SampleConfigurationTest.java</code >
130118 </td >
131119 <td >
132- Shows how to use Spring's <code >@Configuration</code > to create MyBatis beans manually .
120+ 显示如何使用 Spring 的 <code >@Configuration</code > 来手动创建 MyBatis beans .
133121 </td >
134122 </tr >
135123 <tr >
136124 <td >
137125 <code >SampleEnableTest</code >
138126 </td >
139127 <td >
140- Shows how to use Spring's <code >@Configuration</code > with the <code >@MapperScann</code > annotation so
141- mappers are autodiscovered.
128+ 现实如何使用 Spring 的 <code >@Configuration</code > 和 <code >@MapperScann</code > 注解来自动发现 mappers.
142129 </td >
143130 </tr >
144131 <tr >
145132 <td >
146133 <code >SampleNamespaceTest</code >
147134 </td >
148135 <td >
149- Shows how to use the custom MyBatis XML namespace .
136+ 显示如何使用自定义 MyBatis XML 命名空间 .
150137 </td >
151138 </tr >
152139 </tbody >
153140 </table >
154141 <p >
155- Please take a look at the different <code >applicationContext.xml</code > files to see MyBatis-Spring in action .
142+ 查看 <code >applicationContext.xml</code > 文件的区别以进行 MyBatis-Spring 实战 .
156143 </p >
157144
158145 </section >
0 commit comments