JOOQ 为table和view自动生成代码

JOOQ是一个Java的ORM框架,提供了基本的SQL构建、执行等功能,并且使用了链式的API,代码整洁易懂。JOOQ也提供了代码自动生成的功能,也就是根据数据库中的表或者视图生成相应的Java Bean,具体如下,在maven里面添加一个plugin:

            <plugin>
                <groupId>org.jooqgroupId>
                <artifactId>jooq-codegen-mavenartifactId>
                <version>3.9.2version>

                <executions>
                    <execution>
                        <phase>generate-sourcesphase>
                        <goals>
                            <goal>generategoal>
                        goals>
                    execution>
                executions>

                <dependencies>
                    <dependency>
                        <groupId>mysqlgroupId>
                        <artifactId>mysql-connector-javaartifactId>
                        <version>5.1.38version>
                    dependency>
                dependencies>

                <configuration>
                    <jdbc>
                        <driver>com.mysql.jdbc.Driverdriver>
                        <url>${spring.datasource.url}url>
                        <username>${spring.datasource.username}username>
                        <password>${spring.datasource.password}password>
                    jdbc>

                    <generator>

                        <database>
                            
                            
                            <syntheticPrimaryKeys>public\..*\.idsyntheticPrimaryKeys>
                            
                            <overridePrimaryKeys>override_primmary_keyoverridePrimaryKeys>

                            <name>org.jooq.util.mysql.MySQLDatabasename>

                            
                            <includes>.*includes>
                            

                            
                            <inputSchema>xxxxxxinputSchema>
                        database>

                        <generate>
                            
                            <daos>truedaos>
                            <pojos>truepojos>
                            
                            <javaTimeTypes>truejavaTimeTypes>
                            
                            
                            <springAnnotations>falsespringAnnotations>
                        generate>

                        <target>
                            
                            <packageName>com.iot.xxxxx.jooqpackageName>
                            <directory>src/main/javadirectory>
                        target>

                    generator>
                configuration>
            plugin>

你可能感兴趣的:(JOOQ 为table和view自动生成代码)