1、添加依赖
implementation 'com.dameng:DmJdbcDriver18:8.1.3.62'
implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.4'
2、application.yml 数据源配置
spring:
datasource:
driver-class-name: dm.jdbc.driver.DmDriver #com.mysql.cj.jdbc.Driver
url: jdbc:dm://192.168.1.209:5236/SYSDBA?rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
username: SYSDBA
password: dmdba@2025
type: com.alibaba.druid.pool.DruidDataSource
3、ORM实体类
@Data
@TableName(value="DM_USERS")
public class SysUser {
private static final long serialVersionUid=1L;
@TableId(value="USER_ID",type= IdType.AUTO)
private Long id;
@TableField(value="USER_NAME")
private String name;
}
4、Mapper
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
}
5、测试类
@Autowired
private SysUserMapper userMapper;
@Test
public void testDmQuery(){
var users=sysUserMapper.selectList(null);
users.forEach(System.out::println);
}
测试结果