【问题标题】:IntelliJ IDEA not Showing anything endpoints tab: "Failed to retrieve application JMX service URL"IntelliJ IDEA 未显示任何端点选项卡:“无法检索应用程序 JMX 服务 URL”
【发布时间】:2019-07-22 14:27:33
【问题描述】:

我有一个 Spring Boot Web 服务,我想查看它的端点。但是,当我在 IntelliJ 中运行它时,没有显示端点。在端点窗口中,我看到了错误

Failed to check application ready state: AttachProvider for the vm is not found.
Press Refresh button to reinit ready state checking

我能够很好地运行应用程序并使用 SoapUI 很好地访问 Web 服务,但我想使用 IntelliJ 中的功能。当我单击端点选项卡或端点选项卡中的刷新按钮时,在事件日志中我会在应用程序启动时收到一个日志条目,上面写着

PersonMicroserviceApplication: Failed to retrieve application JMX service URL

我在运行配置中选中了“启用 JMX 代理”。这是我的 pom.xml

<?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.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.example.microservice</groupId>
    <artifactId>person-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.datatype</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.module</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

注意:由于安全问题,Jackson 在我公司的 maven 存储库中被标记为隔离依赖项(我不确定安全问题是什么),所以我使用 gson 作为我的 json 映射器,我有以下行在我的 application.properties 中告诉 spring 使用 gson

spring.http.converters.preferred-json-mapper=gson

我的 application.properties 中唯一的另一件事是连接到 mongodb 的字符串。没有别的了,所以我可能在那里遗漏了一些东西,但在 spring 文档中我看到它只是说包括 spring-boot-starter-actuator 并检查启用 JMX 代理。

我在配置方面是否缺少任何东西来启用它?我在 Windows 10 64 位上,我使用的是 oracles JDK 8。

【问题讨论】:

标签: java spring-boot intellij-idea


【解决方案1】:

我也遇到了这个问题,终于找到了答案:

从 2018.3.4 IntelliJ IDEA 开始使用本地 JMX 连接器来检索 Spring Boot 执行器端点的数据。 本地 JMX 监控有一些限制,特别是如果 Spring Boot 应用程序和 IntelliJ IDEA JVM 的位数不同,则无法获取本地 JMX 连接器地址。 如果无法在 JVM 上以相同的位数运行应用程序,则为了解决此问题,可以在 Spring Boot 运行配置的 VM 选项中添加以下内容:

-Dcom.sun.management.jmxremote.port={some_port} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

设置后:

jetbrains 问题链接:https://youtrack.jetbrains.com/issue/IDEA-204797

【讨论】:

  • 相关位:jetbrains.com/help/idea/…(配置选项卡/启用 JMX 代理)
  • {some_port} 是否需要是与应用程序相关的特定端口?还是只是一些随机端口?因为当我使用随机端口时,它仍然对我不起作用。
【解决方案2】:

我在 Windows 10 上使用 IntelliJ Idea 2020.1,我遇到了类似的问题。对我来说,取消选中“启用 JMX 代理”可以解决这个问题。此外,我的系统上同时安装了 JDK 11 和 JDK 8,并且我在不同的 JDK 版本上运行了不同的 Java 应用程序(微服务),但这个需要 JDK 1.8(因为它尚未迁移)。 见附件截图:

【讨论】:

  • 禁用该功能并不是解决该功能不工作的方法。
【解决方案3】:

查看%TMP%/hsperfdata_&lt;username&gt;目录的权限,如果没有读写权限,右键hsperfdata_>properties>security>edit>add>高级添加并确认;
或删除 %TMP%/hsperfdata_ 并重新启动应用程序

https://youtrack.jetbrains.com/issue/IDEA-210665#focus=Comments-27-4410513.0-0 Jconsole and JPS don't show any processes. How can I monitor my process?

【讨论】:

    【解决方案4】:

    我使用的是 Java 1.8 并且遇到了同样的问题,对我来说,通过取消选中运行/调试配置中的启用 JMX 代理来解决它。 参考图片。

    Attached Screenshot

    【讨论】:

    • 禁用该功能并不能解决该功能无法正常工作的问题。
    【解决方案5】:

    在你的虚拟机选项中设置这个:

    -Djava.rmi.server.hostname=localhost

    这对我有用。

    我在这里找到了答案:https://youtrack.jetbrains.com/issue/IDEA-210665#focus=Comments-27-3544328.0-0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-27
      • 2014-03-30
      相关资源
      最近更新 更多