我正在尝试使用QueryDsl从现有数据库中生成类。
当我尝试生成类时,不会生成任何代码。
Pom.xm
我的pom文件如下:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>thinclient-example</groupId>
<artifactId>REDACTED</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<ignite.version>2.6.0</ignite.version>
<querydsl.version>4.2.1</querydsl.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>4.0.3</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<jdbcDriver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbcDriver>
<jdbcUrl>jdbc:sqlserver://REDACTED:1433;databaseName=REDACTED;user=REDACTED;password=REDACTED</jdbcUrl>
<tableNamePattern>.*</tableNamePattern>
<packageName>app.domain</packageName>
<exportAll>true</exportAll>
<!-- Source where to put the generated classes -->
<targetFolder>${project.basedir}/src/main/java</targetFolder>
<sourceFolder>${project.basedir}/src/main/java</sourceFolder>
</configuration>
<dependencies>
<!-- database driver dependencies -->
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre8</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
但是,当我运行mvn com.querydsl:querydsl-maven-plugin:4.2.1:export
时,命令已成功完成,但是没有生成的代码。
如何使它从数据库生成表?
答案 0 :(得分:1)
您的表名过滤器看起来不正确:
<tableNamePattern>.*</tableNamePattern>
文档说:
tableNamePattern - a table name pattern in LIKE pattern form; must match the table name as it is stored in the database, multiple can be separated by comma (default: null)
如果需要为所有数据库表生成类,请从配置中删除tableNamePattern或将其更改为:
<tableNamePattern>%</tableNamePattern>