因此,我尝试与this tutorial一起使用。
我通常与Gradle一起工作,所以我对Maven插件不太了解,但是那里没有太多Gradle,所以... Maven是。
但是当IntelliJ抗议时,当我添加它时找不到properties-maven-plugin
,我进行了一次谷歌搜索,发现this的答案表明我需要检查IntelliJ的use plugin registry
maven设置。
我做到了,IntlliJ接受了该插件。 太好了,让我们添加下一个...
Plugin 'org.codehaus.mojo:sql-maven-plugin:1.5' not found
名称和版本号都显示为红色。
嗯,那不是很好吗? -.- THERE已经血腥使用它了!
如果有人能告诉我正确添加插件所需做的事情,我将非常感激,因为我无法在
上找到该信息。到目前为止,这里是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插入了一个依赖性,也没有提及版本号。 )