Spring Azure applicationinsights 运行时出现 tcnative 错误

启动运行的时候出现错误:

2020-10-20 12:01:21.628 DEBUG 69140 --- [           main] i.n.util.internal.NativeLibraryLoader    : netty_tcnative_windows_x86_64 cannot be loaded from java.library.path, now trying export to -Dio.netty.native.workdir: C:\Users\yhu\AppData\Local\Temp

java.lang.UnsatisfiedLinkError: no netty_tcnative_windows_x86_64 in java.library.path: [C:\Dkits\Java\OpenJDK\11.0.4\bin, C:\windows\Sun\Java\bin, C:\windows\system32, C:\windows, %JAVA_HOME%\bin, %MAVEN_HOME%\bin, %GRADLE_HOME%\bin, C:\Program Files (x86)\NetSarang\Xshell 6\, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, C:\windows\System32\OpenSSH\, C:\Program Files (x86)\Webex\Webex\Applications, C:\Program Files (x86)\Plantronics\Spokes3G\, C:\Program Files (x86)\Enterprise Vault\EVClient\x64\, C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL, C:\Program Files\Intel\Intel(R) Management Engine Components\DAL, C:\Program Files\Intel\WiFi\bin\, C:\Program Files\Common Files\Intel\WirelessCommon\, C:\Program Files\PuTTY\, C:\Program Files (x86)\GnuWin32\bin\, C:\Program Files\nodejs\, C:\Program Files (x86)\Yarn\bin\, C:\Users\yhu\Dkits\protoc\bin\, C:\Program Files\Git\cmd, C:\Program Files\TortoiseGit\bin, C:\Program Files\TortoiseSVN\bin, C:\Program Files\Amazon\AWSCLIV2\, C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\, C:\Dkits\Java\OpenJDK\11.0.4\bin, C:\Users\yhu\Dkits\maven\bin, C:\Users\yhu\Dkits\scala\bin, C:\Dkits\gradle\bin, C:\Users\yhu\AppData\Local\Microsoft\WindowsApps, C:\Users\yhu\AppData\Local\atom\bin, C:\Users\yhu\AppData\Local\Programs\Microsoft VS Code\bin, C:\Users\yhu\AppData\Local\GitHubDesktop\bin, C:\Users\yhu\AppData\Roaming\npm, C:\Users\yhu\AppData\Local\Yarn\bin, C:\Users\yhu\Dkits\protoc\bin, .]
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
	at java.base/java.lang.System.loadLibrary(System.java:1867)

错误原因和分析

这个错误的原因是包的冲突。

如果你的配置文件中有下面 2 个包。

这 2 个包是冲突的。

        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-spring-boot-starter</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>spring-cloud-azure-appconfiguration-config</artifactId>
            <version>1.2.7</version>
        </dependency>

所以你需要将 spring-cloud-azure-appconfiguration-config 这个包删除后才可以启动。