Как вы используете плагины Mojohaus Maven? - PullRequest
0 голосов
/ 18 марта 2019

Так что я пытаюсь следовать этому уроку .

Я обычно работаю с Gradle, поэтому я не слишком разбираюсь в плагинах maven, но Gradle не так уж многобыть там, так что ... Maven это так.

Но когда IntelliJ запротестовал, он не смог найти properties-maven-plugin, когда я его добавил, я немного погуглил и обнаружил это ответ, который предполагал, что мне нужно проверить настройку IntelliJ use plugin registry maven.

Я сделал, и IntlliJ принял плагин.Отлично, давайте добавим следующее ...

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

, где имя и номер версии отображаются красным цветом.

Ну, разве это не здорово?-.- ТАМ да, черт возьми, используйте это уже!

Я был бы очень признателен, если бы кто-то мог сказать мне, что мне нужно сделать, чтобы правильно добавить плагины, потому что я не могунайдите эту информацию о

Вот пока что POM.xml (и я также собираюсь добавить третий плагин, упомянутый в руководстве, как только я заставлю его работать).

<?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>

(Он также не может найти версию H2 в плагине, поэтому я просто удалил <version>1.4.191</version> по сравнению с учебным кодом, так как SpringInitializr также вставил зависимость, которая также не упоминает номер версии.)

...