spring boot整合jooq
專案結構:
JooqConfig.xml全文
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<jdbc>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://11.23.98.90/tableName</url>
<user>root</user>
<password>P@ssw0rd</password>
</jdbc>
<generator>
<!-- 程式碼生成器 -->
<name>org.jooq.util.JavaGenerator</name>
<database>
<!--下面這兩行是為view也生成程式碼的關鍵-->
<!--force generating id'sfor everything in public schema, that has an 'id' field-->
<syntheticPrimaryKeys>public\..*\.id</syntheticPrimaryKeys>
<!--name for fake primary key-->
<overridePrimaryKeys>override_primmary_key</overridePrimaryKeys>
<name>org.jooq.util.mysql.MySQLDatabase</name>
<!--include和exclude用於控制為資料庫中哪些表生成程式碼-->
<includes>.*</includes>
<!--<excludes></excludes>-->
<!--資料庫名稱-->
<inputSchema>suntree_cmp_test</inputSchema>
</database>
<generate>
<!--生成dao和pojo-->
<daos>true</daos>
<pojos>true</pojos>
<!--把資料庫時間型別對映到java 8時間型別-->
<javaTimeTypes>true</javaTimeTypes>
<!--<interfaces>true</interfaces>-->
<!--不在生成的程式碼中新增spring註釋,比如@Repository-->
<springAnnotations>false</springAnnotations>
</generate>
<target>
<!--生成程式碼檔案的包名及放置目錄-->
<packageName>cn.com.suntree.generator</packageName>
<directory>src/main/java</directory>
</target>
</generator>
</configuration>
dependencies中加入
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
</dependency>
plugins中加入
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
</dependencies>
<configuration>
<configurationFile>src/main/resources/JooqConfig.xml</configurationFile>
</configuration>
</plugin>
需要注意的都在JoopConfig.xml中做了註釋
最後執行maven的compile
將會自動生成一些程式碼
初步整合成功
相關文章
- Spring Boot 2.0(八):Spring Boot 整合 MemcachedSpring Boot
- Spring Boot(十八):使用 Spring Boot 整合 FastDFSSpring BootAST
- Spring Boot整合rabbitmqSpring BootMQ
- Spring Boot 整合 rabbitmqSpring BootMQ
- Spring Boot 整合 elasticsearchSpring BootElasticsearch
- Spring Boot 整合 dockerSpring BootDocker
- Spring Boot 整合 elkSpring Boot
- Spring Boot 整合 ApolloSpring Boot
- Spring Boot整合RedisSpring BootRedis
- Spring Boot 整合redisSpring BootRedis
- Spring Boot 整合 MyBatisSpring BootMyBatis
- Spring Boot整合SocketSpring Boot
- Spring Boot 整合 KafkaSpring BootKafka
- spring boot 整合mybatisSpring BootMyBatis
- Spring Boot整合Spring BatchSpring BootBAT
- Spring Boot整合Spring SecuritySpring Boot
- Spring Boot整合Spring AopSpring Boot
- Spring boot學習(三) Spring boot整合mybatisSpring BootMyBatis
- Spring Boot:整合Spring Data JPASpring Boot
- spring-boot+spring-session整合SpringbootSession
- Spring Boot 整合 Apache DubboSpring BootApache
- Spring Boot Actuator 整合 PrometheusSpring BootPrometheus
- spring boot整合HadoopSpring BootHadoop
- spring boot整合shiroSpring Boot
- ElasticSearch與Spring Boot整合ElasticsearchSpring Boot
- spring boot(三)整合 redisSpring BootRedis
- spring-boot整合kindeditorSpringboot
- spring boot 整合測試Spring Boot
- Spring boot 六 整合 MyBatisSpring BootMyBatis
- spring boot 整合shiroSpring Boot
- Spring-Boot整合RedisSpringbootRedis
- Spring Boot系列十九 Spring boot整合 swaggerSpring BootSwagger
- Spring boot學習(四)Spring boot整合DruidSpring BootUI
- Spring Boot系列(三):Spring Boot整合Mybatis原始碼解析Spring BootMyBatis原始碼
- spring-boot 整合 spring-securitySpringboot
- spring-boot 整合 spring-sessionSpringbootSession
- Spring Boot 整合 Elasticsearch 實戰Spring BootElasticsearch
- Solr與Spring Boot整合 - ViithiisysSolrSpring Boot