2022年5月29日更新版本为1.5.9.RELEASE。
我在这里提供了完整的代码和可运行示例https://github.com/surasint/surasint-examples/tree/master/spring-boot-jdbi/9_spring-boot-no-parent(请查看README.txt以了解如何尝试)。
您需要此内容作为基础。
<dependencyManagement>
<dependencies>
<dependency>
<!
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springframework.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
但仅此还不够,你还需要明确定义 spring-boot-maven-plugin 的目标(如果你使用 Spring Boot 作为 parent,则无需显式定义此内容)。
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springframework.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
否则你将无法构建可执行的jar或war文件。
如果你正在使用JSP,那么你需要有以下内容:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
否则,您将收到此错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project spring-boot-09: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executi
ng in update mode) -> [Help 1]
不行,如果你在使用Maven Profile和Resource Filter与Spring Boot一起使用,并且使用"@ "而不是"${}"(例如这个例子 https://www.surasint.com/spring-boot-maven-resource-filter/),那么你需要在中明确添加这个。
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
并且这是在
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
请查看链接中的示例 https://www.surasint.com/spring-boot-with-no-parent-example/。
project-parent
时,我可以将spring-boot-starter-parent
添加到这个project-parent
中吗?在这种情况下,我是否还需要spring-boot-dependencies
?2:普通的 spring-boot 项目我使用spring-boot:run
运行。如何使用不同的父 POM 运行项目? - jsosnowski<properties/>
。 - Dave Syer