mybatis
mybatis官方例子中出了这个类BlogDataSourceFactory,
我也没找到,后开看mybatis包结构发现可以使用下面代码 构建DataSource
1
2
3
4
5
6
7
8
|
Properties properties = new Properties(); properties.setProperty( "driver" , "com.mysql.jdbc.Driver" ); properties.setProperty( "url" , "jdbc:mysql://127.0.0.1:3306/mybatis" ); properties.setProperty( "username" , "root" ); properties.setProperty( "password" , "123456" ); PooledDataSourceFactory pooledDataSourceFactory = new PooledDataSourceFactory(); pooledDataSourceFactory.setProperties(properties); DataSource dataSource = pooledDataSourceFactory.getDataSource(); |
<!-- https://mvnrepository.com/artifact/org.mapstruct/mapstruct-jdk8 -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.2.0.CR1</version>
</dependency>
加上这个就可以用@Mapper注解了,会把UserMapper的接口搞出一个实现类