Skip to content

7.spring集成

codingPao edited this page Dec 28, 2020 · 1 revision

通过简单得注解方式,即可以与spring框架完成集成。

首先增加 POM 依赖

<dependency>
     <groupId>io.manbang</groupId>
     <artifactId>ebatis-spring</artifactId>
     <version>7.5.1.3.RELEASE</version>
</dependency>

增加 Config

@Configuration
@EnableEasyMapper(basePackages = "io.manbang.ebatis.sample.mapper")
public class EbatisConfig {
    @Bean(destroyMethod = "close")
    public ClusterRouter clusterRouter() {
        Cluster cluster = Cluster.simple("127.0.0.1", 9200, Credentials.basic("admin", "123456"));
        ClusterRouter clusterRouter = ClusterRouter.single(cluster);
        return clusterRouter;
    }
}