更新2022-05-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>
<!-- Import dependency management from Spring Boot -->
<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作为父级,你不需要显式地定义这个)
<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]
不不,如果你用“@”而不是“${}”(比如这个例子https://www.surasint.com/spring-boot-maven-resource-filter/)使用Maven配置文件和Spring引导资源过滤器,这仍然是不够的。然后需要显式地添加这个
<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/中的示例。