赞
踩
说明:本文整理拓展自https://github.com/eyougo/mybatis-typehandlers-postgis/blob/master/READM
java1.7或更高版本。
pom.xml文件(这里是第3个依赖,其它依赖请忽略)
- <dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>42.2.5</version>
- </dependency>
- <dependency>
- <!-- https://mvnrepository.com/artifact/org.postgis/postgis-jdbc -->
- <groupId>org.postgis</groupId>
- <artifactId>postgis-jdbc</artifactId>
- <version>1.3.3</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/com.eyougo/mybatis-typehandlers-postgis -->
- <dependency>
- <groupId>com.eyougo</groupId>
- <artifactId>mybatis-typehandlers-postgis</artifactId>
- <version>1.0</version>
- </dependency>
(1)If you are using MyBatis alone, add the type handlers to your mybatis-config.xml as follow:
- <typeHandlers>
- <!-- ... -->
- <typeHandler handler="com.eyougo.mybatis.postgis.type.PointTypeHandler" />
- <typeHandler handler="com.eyougo.mybatis.postgis.type.PolygonTypeHandler" />
- </typeHandlers>
(2)If you are using MyBatis with Spring, add the type handlers package to the Spring configuration as follow:
With XML Configuration
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <!-- ... -->
- <property name="typeAliasesPackage" value="com.eyougo.mybatis.postgis.type" />
- </bean>
Or with Java configuration
- @Bean
- public SqlSessionFactory sqlSes
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。