jOOQ和Spring Boot pom.xml配置问题

问题描述 投票:0回答:1

我正在尝试在pom.xml中使用以下配置来设置jOOQ和Spring Boot项目:

[当我运行mvn package -Pgenerate创建类时,我收到一条消息,说

[WARNING] The requested profile "generate" could not be activated because it does not exist.

尽管发出警告,构建仍完成,但是target / generated-sources / jooq文件夹中以及src文件夹中的任何地方都没有生成任何类。

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.demo.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>


    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jooq -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jooq</artifactId>
            <version>2.3.0.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.20</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>

                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <version>3.13.2</version>

                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>

                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.20</version>
                    </dependency>
                </dependencies>

                <configuration>

                    <jdbc>
                        <driver>com.mysql.jdbc.Driver</driver>
                        <url>jdbc:mysql://localhost:3306/visitorlog?serverTimezone=UTC</url>
                        <user>root</user>
                        <password>root</password>
                    </jdbc>

                    <generator>
                        <database>
                            <name>org.jooq.meta.mysql.MySQLDatabase</name>
                            <includes>.*</includes>
                            <excludes></excludes>
                            <!-- In case your database supports catalogs, e.g. SQL Server:
                            <inputCatalog>public</inputCatalog>
                              -->
                            <inputSchema>public</inputSchema>
                        </database>
                        <target>
                            <packageName>com.demo.example.demo</packageName>
                            <directory>target/generated-sources/jooq</directory>
                        </target>
                    </generator>
                </configuration>
            </plugin>
        </plugins>


    </build>

</project>
java spring spring-boot maven jooq
1个回答
1
投票

[-Pgenerate表示激活配置文件生成,但是您没有配置文件生成。

您可能想要做的是运行jOOQ代码生成

mvn jooq-codegen:generate

这也可以这样绑定到Maven阶段:

<execution>
    <id>jooq-codegen</id>
    <phase>generate-sources</phase>
    <goals>
       <goal>generate</goal>
    </goals>
</execution>

因此,当您进行maven编译时,它还将生成jOOQ代码。

© www.soinside.com 2019 - 2024. All rights reserved.