用1.5.9.RELEASE更新2018-01-04。
我在这里有完整的代码和可运行的示例https://www.surasint.com/spring-boot-with-no-parent-example/
您需要此作为基本
<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]
否否,如果您使用带有“ @”而不是“ $ {}”的带有Spring Boot的Maven配置文件和资源过滤器,那么这还不够(例如此示例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/中的示例。