【问题标题】:Spring-boot(maven) actuator,devtools not workingSpring-boot(maven)执行器,devtools不工作
【发布时间】:2019-01-29 05:44:01
【问题描述】:

我是 spring-boot 的新手。尝试使用 spring-boot maven 创建一个简单的 Web 应用程序。使用依赖项spring-boot-starter-web 的基本静态页面显示效果很好。当我在pom.xml 中包含spring-boot-devtoolsspring-boot-starter-actuator 时,会出现构建错误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 网站)下载了这个项目。构建项目失败。

【问题讨论】:

    标签: maven spring-boot


    【解决方案1】:

    spring-boot-devtools 中的&lt;scope&gt;runtime&lt;/scope&gt; 假设不是运行时。事实上根据文档 -

    开发者工具在完全运行时会被自动禁用 打包的应用程序。如果您的应用程序是从 java -jar 启动的 或者如果它是从一个特殊的类加载器启动的,那么它被认为是 “生产应用程序”。将依赖项标记为可选 Maven 或在 Gradle 中使用 customdevelopmentOnly 配置(如 如上所示)是防止开发工具被 可传递地应用于使用您项目的其他模块。

    所以,改变依赖如下 -

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    

    【讨论】:

      【解决方案2】:

      您可以更新您的 pom.xml 并将版本号更改为任何以前的稳定版本。它对我有用。

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>**xyz_previous_.RELEASE**</version>
      <relativePath/> <!-- lookup parent from repository -->
      

      【讨论】:

        猜你喜欢
        • 2014-09-11
        • 2017-11-10
        • 2023-04-05
        • 2017-08-26
        • 1970-01-01
        • 2014-04-07
        • 2017-11-21
        • 2021-03-02
        • 2021-07-15
        相关资源
        最近更新 更多