0

So I'm trying to follow along with this tutorial.

I usually work with Gradle, so I'm not too savvy about maven plugins, but there's not much Gradle to be had out there, so ... Maven it is.

But when IntelliJ protested it couldn't find the properties-maven-plugin when I added it, I did some googling and found this answer which suggested I needed to check IntelliJ's use plugin registry maven setting.

I did, and IntlliJ accepted the plugin. Great, let's add the next ...

Plugin 'org.codehaus.mojo:sql-maven-plugin:1.5' not found

with both the name and the version number displayed in red.

Well, isn't that great? -.- THERE it is, bloody use it, already!

I'd really appreciate it if somebody could tell me what I need to do to add the plugins correctly, because I cannot find that information on the

Here's the POM.xml, so far (and I also intend to add the third plugin mentioned on the tutorial, as soon as I got this one to work).

<?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 http://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.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>some.where</groupId>
    <artifactId>foo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>foo</name>
    <description>Simple project to test Spring Boot and JOOQ</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jooq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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


            <!--
            Note: to add the following plugins in IntelliJ, go into IntelliJ's Maven settings and check the
                  'use plugin registry'
                  option
            -->

            <plugin>
                <!--https://www.baeldung.com/jooq-with-spring:
                This plugin is used to read configuration data from a resource file.
                It is not required since the data may be directly added to the POM,
                but it is a good idea to manage the properties externally.
                (Here: it's reading the `application.properties` file)

                The read-project-properties goal of this plugin should be bound to an early phase
                so that the configuration data can be prepared for use by other plugins.
                In this case, it is bound to the initialize phase.

                In it, we'll define properties for database connections, including the
                    JDBC driver class,
                    database URL,
                    username,and
                    password
                -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.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>

            <!-- now WHY won't the plugin work THIS time ?! -->

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <driver>${db.driver}</driver>
                            <url>${db.url}</url>
                            <username>${db.username}</username>
                            <password>${db.password}</password>
                            <srcFiles>
                                <srcFile>src/main/resources/intro_schema.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                    </dependency>
                </dependencies>
            </plugin>



        </plugins>
    </build>
</project>

(It also cannot find the H2 version in the plugin so I just removed the <version>1.4.191</version> when compared to the tutorial code, since there's also a dependency inserted by the SpringInitializr that doesn't mention a version number either.)

User1291
  • 7,664
  • 8
  • 51
  • 108
  • can you try executing "mvn dependency:go-offline" once? IntelliJ sometimes does not download all dependencies and plugins automatically. The goal gets all things mentioned in your pom. then reload the project (reload icon in the maven panel). That should do – wemu Mar 18 '19 at 22:31
  • First I would ask: Why do you need properties-maven-plugin in a Spring Boot Project? Please explain your use case? Furthermore I would also questioning using sql-maven-plugin in that way? Cause you have things like flyway etc. available via Spring Boot ? – khmarbaise Mar 21 '19 at 10:11

0 Answers0