在主鍵上增長註解java
@Id @GeneratedValue(generator="UUID") private String id;
@Configuration public class TkMapperConfig { @Bean public MapperScannerConfigurer mapperScannerConfigurer(){ MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); mapperScannerConfigurer.setBasePackage("com.xxxx.dao"); Properties propertiesMapper = new Properties(); //通用mapper位置,不要和其餘mapper、dao放在同一個目錄 propertiesMapper.setProperty("mappers", "com.xxxx.Mapper"); propertiesMapper.setProperty("notEmpty", "false"); //主鍵UUID回寫方法執行順序,默認AFTER,可選值爲(BEFORE|AFTER) propertiesMapper.setProperty("ORDER","BEFORE"); mapperScannerConfigurer.setProperties(propertiesMapper); return mapperScannerConfigurer; } }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "select uuid()") private String id;
在主鍵上增長註解mysql
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
@Id @GeneratedValue(generator = "JDBC") private Long id;