Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>en</locales>
<locales>en,zh_CN</locales>
</configuration>
</plugin>
</plugins>
Expand Down
35 changes: 35 additions & 0 deletions src/site/site_zh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2013-2022 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd"
name="${project.name}">

<body>
<menu name="参考文档">
<item name="简介" href="index.html"/>
<item name="入门" href="getting-started.html"/>
<item name="注入组件" href="injection.html"/>
<item name="事务" href="transactions.html"/>

<item name="重大变化" href="changes.html"/>
</menu>

<menu ref="reports"/>
</body>
</project>
30 changes: 30 additions & 0 deletions src/site/zh/resources/css/site.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2009-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* when new flags are needed, take them from
*
* http://www.printableworldflags.com/flag-icon
*
* that are free for any kind of usage
*/

ul.i18n {list-style-type:none;}
li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}

45 changes: 45 additions & 0 deletions src/site/zh/xdoc/changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2013-2022 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">

<properties>
<title>MyBatis-CDI | beta4 版本以来的重大变化</title>
<author email="mnesarco@gmail.com">Frank Martinez</author>
<author email="eduardo.macarron@gmail.com">Eduardo Macarron</author>
<author email="awxiaoxian2020@163.com">Xavi Lee</author>
</properties>

<body>
<section name="Breaking changes since beta4">
<p>
为了使该模块更加友好, <code>@Mapper</code> 接口被移动到 Mapper 接口本身,现在 SqlSessionFactory 生产者必须使用新的注jie<code>@SessionFactoryProvider</code>。
</p>
<ol>
<li>
<code>@Mapper</code> 注解现在是Mapper接口中的必填项,禁止在注入点中使用该注解。
</li>
<li>
<code>@SessionFactoryProvider</code> 现在在 SqlSessionFactory 生产者中是必需的。
</li>
</ol>
</section>
</body>

</document>
114 changes: 114 additions & 0 deletions src/site/zh/xdoc/getting-started.xml.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2013-2022 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">

<properties>
<title>MyBatis-CDI | 入门</title>
<author email="mnesarco@gmail.com">Frank Martinez</author>
<author email="eduardo.macarron@gmail.com">Eduardo Macarron</author>
<author email="awxiaoxian2020@163.com">Xavi Lee</author>
</properties>

<body>
<section name="Getting Started">
<p>
这一章节将向你展示 MyBatis-CDI 的安装步骤。
</p>

<subsection name="Installation">
<p>
要使用 MyBatis-CDI 模块,你只需要将 <code>mybatis-cdi-${project.version}.jar</code>
文件和它的依赖置于类路径中。
</p>
<p>
如果你使用 Maven, 只需要将以下依赖添加到你的 pom.xml 中:
</p>
<source><![CDATA[
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-cdi</artifactId>
<version>${project.version}</version>
</dependency>]]></source>
</subsection>

<subsection name="Quick Setup">

<p>
首先,开启 MyBatis-CDI 需要向你的 <code>META-INF</code> 文件夹中添加 <code>beans.xml</code> 文件。
</p>

<p>
接下来,使用 MyBatis-CDI 至少需要两样东西:
<code>SqlSessionFactory</code> 和用于注入 Mybatis mapper 的 CDI 组件(bean).
</p>

<p>
创建一个生成器(producer)方法,返回一个应用域(application scoped)的 <code>SqlSessionFactory</code> 并带有 <code>@SessionFactoryProvider</code> 注解:
</p>

<source><![CDATA[
import javax.enterprise.inject.Produces;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.cdi.SessionFactoryProvider;

public class SqlSessionFactoryProvider {

@Produces
@ApplicationScoped
@SessionFactoryProvider
public SqlSessionFactory produceFactory() {
SqlSessionFactory factory = create the factory instance ....
return factory;
}

}]]></source>

<p>
假定你有一个像下面这样的 mapper 接口(注意:必须在 mapper 上添加 <code>@Mapper</code> 注解):
</p>
<source><![CDATA[
@Mapper
public interface UserMapper {
@Select("SELECT * FROM users WHERE id = #{userId}")
User getUser(@Param("userId") String userId);
}

]]></source>

<p>
你可以使用 <code>@Inject</code> 将任意的依赖注入到 CDI 组件中去:
</p>

<source><![CDATA[
import javax.inject.Inject;

public class FooServiceImpl implements FooService {

@Inject UserMapper userMapper;

public User doSomeStuff(String userId) {
return this.userMapper.getUser(userId);
}

]]></source>
</subsection>
</section>
</body>
</document>
65 changes: 65 additions & 0 deletions src/site/zh/xdoc/index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2013-2022 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">

<properties>
<title>MyBatis-CDI | 简介</title>
<author email="eduardo.macarron@gmail.com">Eduardo Macarron</author>
<author email="mnesarco@gmail.com">Frank Martinez</author>
<author email="awxiaoxian2020@163.com">Xavi Lee</author>
</properties>

<body>
<section name="Introduction">
<subsection name="What is MyBatis-CDI?">
<p>
MyBatis-CDI 扩展负责 MyBatis 映射器和 <code>SqlSession</code> 的生命周期。 MyBatis 组件直接注入 CDI 组件即可使用,无需创建或销毁它们。
它还提供本地和 JTA 事务支持,基于 <code>@Transactional</code> 注解。
</p>
</subsection>

<subsection name="Requirements">
<p>
在开始使用 MyBatis 与 CDI 的集成框架之前,必须熟悉 MyBatis 和 CDI 的术语。本文档不提供 MyBatis 或 CDI 的背景信息或基本设置和配置教程。
</p>
<p>
MyBatis - CDI 需要 Java EE 6 或更高版本以及任意的 MyBatis 版本。
</p>
</subsection>

<subsection name="Help make this documentation better…">
<p>
如果你发现此文档在任何方面有所欠缺,或者缺少某个功能的文档,那么最好的做法是了解它,然后自己编写文档!
</p>
<p>
本手册的源文件以 xdoc 格式提供,网址为:
<a href="https://github.com/mybatis/cdi/tree/master/src/site">项目的 Git 仓库</a>
Fork 这个仓库,更新它们,并提交 Pull Request 吧!
</p>
<p>
你是本文档的最佳作者,开始阅读它吧!
</p>
</subsection>

</section>
</body>

</document>
Loading