You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kotlin SpringBoot本地连接Azure Application Insights找不到连接串问题

解决Azure Application Insights 3.4.3版本"No connection string provided"报错

一、配置自定义JSON配置文件的步骤

1. 创建自定义配置文件

在项目的src/main/resources目录下创建目标配置文件(比如applicationinsights-dev.json),填入以下示例内容并替换实际参数:

{
  "connectionString": "你的Application Insights连接字符串",
  "role": {
    "name": "你的服务名称"
  }
}

2. 添加JVM启动参数

根据不同运行场景配置启动参数:

  • 本地IDE运行(如IntelliJ IDEA):
    打开Run/Debug Configurations,在VM options中添加:
    -Dapplicationinsights.runtime-attach.configuration.classpath.file=applicationinsights-dev.json
    
  • 命令行运行jar包:
    使用以下命令启动应用:
    java -Dapplicationinsights.runtime-attach.configuration.classpath.file=applicationinsights-dev.json -jar 你的应用jar包名称.jar
    
  • Maven插件运行:
    在pom.xml的spring-boot-maven-plugin节点中添加JVM参数配置:
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <jvmArguments>
          -Dapplicationinsights.runtime-attach.configuration.classpath.file=applicationinsights-dev.json
        </jvmArguments>
      </configuration>
    </plugin>
    

二、额外排查要点

  • 确认连接字符串完全正确,直接从Azure Portal的Application Insights实例中复制,避免多余空格或字符。
  • 检查自定义配置文件是否在类路径下,编译后需能在target/classes目录中找到该文件。
  • 若使用runtime attach方式,确保agent包已正确引入,版本与配置逻辑匹配。

内容的提问来源于stack exchange,提问作者Mervyn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 23:28:11