目前正在迁移我的spring-boot应用程序,以使用最新的兼容版本的JDK 8。我目前收到此错误时,运行spring-boot-app
ightsTelemetryAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'azure.application-insights-com.microsoft.applicationinsights.boot.ApplicationInsightsProperties': Initialization
of bean failed; nested exception is java.lang.NoSuchFieldError: Companion
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5218)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1016)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1903)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webRequestTrackingFilterRegistrationBean' defined in class path resource [com/microsoft/applicationinsights/boot/ApplicationInsightsWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method
'webRequestTrackingFilterRegistrationBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.microsoft.applicationinsights.boot.ApplicationInsightsTelemetryAutoConfiguration': Unsatisfied dependency expressed through constructor paramet
er 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'azure.application-insights-com.microsoft.applicationinsights.boot.ApplicationInsightsProperties': Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: Companion
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
字符串
我的applicationinsights版本是spring-boot-starter-parent 2.7.12,spring-cloud-dependencies 2021.0.3和spring-cloud-starter-bootstrap。我更新到了applicationinsights的最新版本,但仍然收到同样的错误。
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.6.4</version>
</dependency>
型
我更新了以下工件,还添加了spring-cloud-starter-bootstrap依赖项
| 伪影|先前版本|更新版本|
| --|--|--|
| Spring Boot启动器父母| 2.2.4.RELEASE |2.7.12|
| spring-cloud-dependency| Finchley.M9 |2021.0.3|
| applicationinsights-spring-boot-starter| 1.0.0-BETA |2.6.4|
| 应用程序洞察日志|2.1.1| 2.6.4|
1条答案
按热度按时间2ledvvac1#
该错误似乎是由于
azure.application-insights-com.microsoft.applicationinsights.boot.ApplicationInsightsProperties
bean的初始化(或)由于Azure Application Insights包和您正在使用的Sping Boot 之间的版本不兼容而发生的。尝试升级/降级与您的 *Sping Boot 版本 * 兼容的 *Azure Application Insights库版本 *。
(或)
ApplicationInsights
包2.6.4版本。*升级版本后运行
mvn clean install
。x1c 0d1x的数据
备选案文:
applicationinsights-spring-boot-starter
软件包用于配置Application Insights的旧方法。applicationinsights-runtime-attach
来配置AppInsights。字符串
pom.xml:
型
在
src>main>resources
文件夹下创建applicationinsights-dev.json
并添加:型
在
applications.properties
中添加以下配置:型
**main()
型
参考资料:
Upgrading from 2.x - Azure Monitor Application Insights Java - Azure Monitor | Microsoft LearnConfigure Azure Monitor Application Insights for Spring Boot - Azure Monitor | Microsoft Learn