2

I want to use Data in *.properties...

This is my application.properties file

spring.datasource.url=jdbc:postrgresql://host:port/dbName 
spring.datasource.username=username
spring.datasource.password=password

and my "jooq-codegen-plugin" in <build> in pom.xml

<plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>42.2.23</version>
                </dependency>
            </dependencies>
            <configuration>
                <jdbc>
                    <driver>org.postgresql.Driver</driver>
                    <user>${spring.datasource.username}</user>
                    <password>${spring.datasource.password}</password>
                    <url>${spring.datasource.url}</url>
                </jdbc>
                <generator>
                    <database>
                        <name>org.jooq.meta.postgres.PostgresDatabase</name>
                        <includes>.*</includes>

                        <inputSchema>public</inputSchema>
                    </database>
                    <target>
                        <packageName>com.wavers.hwacha.generated.jooq</packageName>
                        <directory>src/main/java/</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>

and Part of Error when I run enter image description here

[INFO] Database parameters      
[INFO] ----------------------------------------------------------
[INFO]   dialect                : POSTGRES
[INFO]   URL                    : 

and another error message

Cannot execute query. No Connection configured

I guess that url info written at pom.xml do not map...

I Can't find any way... help me

1 Answers1

0

This is mostly a question of how to read properties into a pom.xml in general. One option is this one:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.1.0</version>
    <executions>
        <execution>
            <phase>initialize</phase>
            <goals>
                <goal>read-project-properties</goal>
            </goals>
            <configuration>
                <files>
                    <file>src/main/resources/application.properties</file>
                </files>
            </configuration>
        </execution>
    </executions>
</plugin>
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Thanks! but i try to the way, it do not read parameter in application.properties.. – beginOfBegin Jun 03 '22 at 04:32
  • @beginOfBegin: I don't know what you tried *specifically*, but this is one way how you can read properties and use them in your `pom.xml`. You can use the [`maven-echo-plugin` or `groovy-maven-plugin` to print out your properties for debugging purposes](https://stackoverflow.com/a/15764995/521799) – Lukas Eder Jun 03 '22 at 06:38