我是 spring-boot 的新手。尝试使用 spring-boot maven 创建一个简单的 Web 应用程序。使用依赖项
spring-boot-starter-web
的基本静态页面显示效果很好。当我将 spring-boot-devtools
和 spring-boot-starter-actuator
包含在 pom.xml
中时,它给出了构建错误 Re-run Maven using the -X switch to enable full debug logging
。
我尝试在 pom 文件中包含
spring-webmvc
依赖项,结果仍然相同。
<?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.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.test</groupId>
<artifactId>jspTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jspTest</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</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>
</plugins>
</build>
我从
spring.io
(SPRING INITIALIZR 网站)下载了这个项目。构建项目失败了。
<scope>runtime</scope>
的 spring-boot-devtools
假设不是运行时。事实上,根据文档 -
完全运行时,开发者工具会自动禁用 打包的应用程序。如果您的应用程序是从 java -jar 启动的 或者如果它是从特殊的类加载器启动的,那么它被认为是 “生产应用程序”。将依赖项标记为可选 Maven 或在 Gradle 中使用自定义
配置(如 如上所示)是防止开发工具被 传递地应用于使用您的项目的其他模块。developmentOnly
因此,更改依赖关系如下 -
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
您可以更新您的 pom.xml 并将版本号更改为任何以前的稳定版本。这对我有用。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>**xyz_previous_.RELEASE**</version>
<relativePath/> <!-- lookup parent from repository -->